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
online casino casino real money online slots
Dgytdg nkeepl generic viagra sales How to get some viagra
http://casinoslotspc.com/ slots online best online casinos slots for real money casino real money
casino bonus codes slot games real casino slots play online casino
free casino games online http://casinorealmoneyfdr.com/ - free casino play online casino slots games
http://casinogamespqr.com/ casino game big fish casino world class casino slots real casino slots
http://casinorealmoneyfdr.com/ casino slots http://casinorealmoneyfdr.com/ - free casino online gambling
real money casino http://casinogamespqr.com/ - slots free big fish casino vegas slots online
http://casinorealmoneyfdr.com/ online casino games http://casinorealmoneyfdr.com/ - online gambling play slots
play online casino free slots games slot games online slots http://casinogamespqr.com/ - online slots
online casinos casino slots slot games
free casino games online online casino games online casino slots online casino
online casino bonus free slots free casino best online casino
best online casinos http://casinorealmoneyfdr.com/ casino online online gambling slots games
http://casinoslotsfest.com/ world class casino slots http://casinoslotsfest.com/ - casino blackjack best online casino
Krcfkq wzfqel Low cost canadian viagra Buy viagra no prescription
online casino slots free casino games slots online play slots online
slots online casino game casino bonus codes online slots
slots online casino game casino bonus codes online slots
casino play online casino slots slots free
casino play online casino slots slots free
Eazqgu fecchs Price check 50mg viagra Buy viagra now online
Eazqgu fecchs Price check 50mg viagra Buy viagra now online
casino games http://casinoslotsfest.com/ casino play casino real money casino online
casino games http://casinoslotsfest.com/ casino play casino real money casino online
online casino real money online casino slots free online slots
casino bonus codes casino online slots real casino slots casino games http://casinoslotsfest.com/ - online casino games
online gambling online slot games play online casino
online gambling online slot games play online casino
online gambling online slot games play online casino
online gambling online slot games play online casino
free casino http://casinoslotsfest.com/ - free slots games casino real money free slots games
casino online slots free slots free slots games play online casino http://casinorealmoneyfdr.com/ - online slot games
Xkslte bwwteh Viagra alternative Buy viagra online cheap
free casino http://casinoslotsfest.com/ - online gambling online casino games online casino gambling free casino games online
free casino http://casinoslotsfest.com/ - online gambling online casino games online casino gambling free casino games online
world class casino slots slot games casino real money
best online casinos http://onlinecasinofbk.com/ - play slots slots free best online casinos casino online
best online casinos http://onlinecasinofbk.com/ - play slots slots free best online casinos casino online
best online casinos http://onlinecasinofbk.com/ - play slots slots free best online casinos casino online
http://casinoslotsfest.com/ slot games casino online online casino bonus online gambling
casino real money http://onlinecasinofbk.com/ - free casino slot games free casino slot games online casino real money free casino slot games
casino real money http://onlinecasinofbk.com/ - free casino slot games free casino slot games online casino real money free casino slot games
casino real money http://onlinecasinofbk.com/ - free casino slot games free casino slot games online casino real money free casino slot games
play slots http://casinoslotsfest.com/ - big fish casino free casino games online online casino slots
play slots http://casinoslotsfest.com/ - big fish casino free casino games online online casino slots
best online casinos http://onlinecasinofbk.com/ - world class casino slots real casino slots big fish casino
online casino bonus slots online play online casino slots online http://casinoslotsfest.com/ - cashman casino slots
online casino games http://onlinecasinofbk.com/ online casino games free casino games online slot games
online casino games http://onlinecasinofbk.com/ online casino games free casino games online slot games