Here is a pretty way to use SSH with PHP.
Please note that this method required to install libssh2 for PHP on the server.
$host = "127.0.0.1"; $port = 22; $conn = ssh2_connect($host); $public_key_realpath = '/.ssh/yourkey.pub'; $private_key_realpath = '/.ssh/yourkey'; $username = 'ssh-username'; $key_password = '123456'; if ($conn) { ssh2_auth_pubkey_file( $conn, $username, $public_key_realpath, $private_key_realpath, $key_password ); }
By the way, if you want to connect with username and password only (and your server allows this) - use this:
ssh2_auth_password($conn, 'username', 'password'); // use this instead of ssh2_auth_pubkey_file
To send the file, like you doing that with SCP:
// send a file ssh2_scp_send($conn, '/local/filename', '/remote/filename', 0755); // fetch file ssh2_scp_recv($conn, '/remote/filename', '/local/filename');
Other jobs with folders and files looks like this (using SFTP wrapper):
$sftp = ssh2_sftp($conn); // Create a new folder ssh2_sftp_mkdir($sftp, '/home/username/newdir'); // Rename the folder ssh2_sftp_rename($sftp, '/home/username/newdir', '/home/username/newnamedir'); // Remove the new folder ssh2_sftp_rmdir($sftp, '/home/username/newnamedir'); // Create a symbolic link ssh2_sftp_symlink($sftp, '/home/username/myfile', '/var/www/myfile'); // Remove a file ssh2_sftp_unlink($sftp, '/home/username/myfile');
To execute custom SSH command you just do like this:
$stream = ssh2_exec($conn, 'sudo apt-get install nano');
×
Comments
Mublwv yjovrb generic cialis online pharmacy online
Mublwv yjovrb generic cialis online pharmacy online
Cueelh fltoay Us cialis sales canadian pharmacy
Drgbwn mudths generic cialis online canadian pharmacy
Zsivpq eqhwem Buy cialis canada online pharmacy
Zsivpq eqhwem Buy cialis canada online pharmacy
Woyotc usdlfu order levitra
viagra cialis buy safe paypal https://bbuycialisss.com/ - Cialis Canada Phamacy п»їcialis Ce Qui Est Amoxil
viagra cialis buy safe paypal https://bbuycialisss.com/ - Cialis Canada Phamacy п»їcialis Ce Qui Est Amoxil
Qcrhkc awnwhg levitra vardenafil
Qcrhkc awnwhg levitra vardenafil
Pcrbih lxcyvz buy levitra ed pills otc
Rcyzai jwtxgk super kamagra cheap erectile dysfunction pills
Xpjhhs sysyps legitimate online slots for money online casino usa
Xpjhhs sysyps legitimate online slots for money online casino usa
Xpjhhs sysyps legitimate online slots for money online casino usa
Jxpehj jpzpkj order vardenafil canadian pharmacy online
Jxpehj jpzpkj order vardenafil canadian pharmacy online
Jxpehj jpzpkj order vardenafil canadian pharmacy online
Jxpehj jpzpkj order vardenafil canadian pharmacy online
Llygmp sxfnwj casinos online free slots
Bbxeqe kmyuqn generic cialis canada walmart pharmacy
Kvthpe wqrwla finasteride online pills for erection
Generic Levitra For Sale In Us https://bbuycialisss.com/ - Buy Cialis Tarif Levitra 10mg Cialis Derniere Plus
Generic Levitra For Sale In Us https://bbuycialisss.com/ - Buy Cialis Tarif Levitra 10mg Cialis Derniere Plus
Generic Levitra For Sale In Us https://bbuycialisss.com/ - Buy Cialis Tarif Levitra 10mg Cialis Derniere Plus
foro viagraespana https://bbuycialisss.com/ - Cialis foros donde comprar viagra generic cialis online pharmacy foros viagra
foro viagraespana https://bbuycialisss.com/ - Cialis foros donde comprar viagra generic cialis online pharmacy foros viagra
Qutxse jldoma viagra online canadian pharmacy best non prescription ed pills
Tjzznb vzwpdd generic viagra cost online ed medications
Amoxicillin Doasge For Children https://bbuycialisss.com/ - Cialis Cialis Blutdrucksenker Cialis Levothyroxine 0.2mg
Lteoxr ynbhum vegas casino online betfair casino online nj
Lteoxr ynbhum vegas casino online betfair casino online nj
Bltomi nichqn buy viagra online Viagra 50 mg
Qeennh zzxczh casino online games slot games online
Gezjhw hwjnmu casinos online slots real money
Bcbrrt mgbwua no credit check payday loans installment loans
Ktnbdg vjlwqk quick cash loans casino online usa
Ktnbdg vjlwqk quick cash loans casino online usa
Dvgiia plfskw cialis generic cialis online pharmacy
Dvwomp bpbdlv payday loan online payday loans online
Clgmgg xqevsa online payday loan online casino real money usa
Pmfhex zxbvly same day cash loans real online casino
Ukffhh ikfelm personal loan bad credit cash advance loans
Mdczij irsdbc easy payday loans payday lenders
Eoprwu sswhqe antibiotics without a doctorвЂs prescription amoxicillin
Eoprwu sswhqe antibiotics without a doctorвЂs prescription amoxicillin
Mmqhum lyuhtk buy furosemide online furosemide 40mg
Gztcuw zegibx Proviron Zenegra online
Mgkluo xnuvpb azithromycin side effects azithromycin 250 mg side effects azithromycin z pack