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
http://cbdoilglk.com/ cbd hemp cbd pure cbd medic buy cbd oil
cbd vape http://cbdoilglk.com/ - hemp oil for pain cdb oils pure cbd oil cdb oils
cbd tinctures http://buycbdoilwalm.com/ - cbd for dogs cbd hemp cbd store cbd hemp
cbd tinctures http://buycbdoilwalm.com/ - cbd for dogs cbd hemp cbd store cbd hemp
cbd cream cbd oils cbd cream medterra cbd
cbd cream cbd oils cbd cream medterra cbd
cbd vape http://buycbdoilwalm.com/ - pure cbd oil cbd gummies best cbd oil
cbd oil for dogs http://buycbdoilwalm.com/ - cbd oil at walmart cbd gummies medterra cbd buy cbd oil online
cbd for dogs http://buycbdoilwalm.com/ hemp cbd buy hemp oil cbd cream
http://buycbdoilwalm.com/ buy cbd cbd oil at walmart cbd gummies walmart hemp cbd oil
cbd for dogs http://buycbdoilwalm.com/ buy cbd buy cbd medterra cbd
cbd pure http://buycbdoilwalm.com/ hemp cbd best cbd oil cbd oil at walmart
cbd pure http://buycbdoilwalm.com/ hemp cbd best cbd oil cbd oil at walmart
hemp oil cbd store cannabis oil cbd gummies walmart
cbd oil for sale http://buycbdoilwalm.com/ - cbd oils medterra cbd hemp cbd oil
http://buycbdoilonline.us.com/ buy cbd cbd online cbd oil store cbd oil at walmart
hemp cbd cbd cream cbd products cannabis oil
http://buycbdoilonline.us.com/ cbd hemp cbd oil for dogs cbd for sale medterra cbd
cbd oil for dogs http://cbdoilrx.us.com/ - cbd gummies walmart cbd for sale cbd for dogs
cbd oil for dogs http://cbdoilrx.us.com/ - cbd gummies walmart cbd for sale cbd for dogs
cbd http://buycbdoilonline.us.com/ - cbd gummies hemp oil cbd gummies walmart
cbd gummies cbd oil for dogs cbd store
Csipvy chvckp generic ed pills impotence pills
buy hemp oil http://buycbdoilonline.us.com/ - cbd online buy cbd oil online medterra cbd cbd tinctures
cbd for sale http://buycbdoilonline.us.com/ cbd drops buy cbd oil online cbd oil benefits
Dhfwmc ffquhg buy ed pills best ed pills
Dhfwmc ffquhg buy ed pills best ed pills
Xokijj bfyaip best otc ed pills ed pills for sale
Knstbj sscqwu erectile dysfunction pills best ed pills at gnc
Knstbj sscqwu erectile dysfunction pills best ed pills at gnc
Mcykyi lhczhq generic cialis 2020 otc ed pills
Nynoqy yqixil Buy viagra Buy viagra brand
Nynoqy yqixil Buy viagra Buy viagra brand
Where To Buy Tadalis Sx Soft Online https://buyciallisonline.com/ - buy cialis daily online No Rx Cephalexin Buy Cialis Generika Viagra Erfahrungen
Where To Buy Tadalis Sx Soft Online https://buyciallisonline.com/ - buy cialis daily online No Rx Cephalexin Buy Cialis Generika Viagra Erfahrungen
Hdezai ijycop canadian pharmacy canada online pharmacy
Plkbwy wvaehp best canadian online pharmacy rx pharmacy
Qizpqe elqrma real canadian pharmacy rx pharmacy
Qizpqe elqrma real canadian pharmacy rx pharmacy
Qizpqe elqrma real canadian pharmacy rx pharmacy
Mdvtvy erpxgk viagra online Overnight viagra
Mdvtvy erpxgk viagra online Overnight viagra
Gcrfft xnnked Viagra next day delivery Rx generic viagra
Gcrfft xnnked Viagra next day delivery Rx generic viagra
Gcrfft xnnked Viagra next day delivery Rx generic viagra
genuine cialis 5mg https://cheapcialisir.com/ - Cialis Zithromax Treatment For Gonorrhea safe place to buy cialis online Medicament Zithromax
genuine cialis 5mg https://cheapcialisir.com/ - Cialis Zithromax Treatment For Gonorrhea safe place to buy cialis online Medicament Zithromax
Bdphmu hqnxxs Buy viagra online 50mg viagra
Vlseba pvznyu Buy viagra canadian pharmacy online
Vlseba pvznyu Buy viagra canadian pharmacy online