Push SSH public-key to VPS make it faster to ssh/sftp

Push SSH public-key to VPS make it faster to ssh/sftp

Posted: 9 years ago in  Unix | Miscellaneous |


Each VPS provided by companies should have admin control panel to add public key to get rid of password-authentication each time you ssh to server. However, in few case, CP will cost you or VPS reseller do not suggest that management, you still have the way to add key to VPS.


Each VPS provided by companies should have admin control panel to add public key to get rid of password-authentication each time you ssh to server.
However, in few case, CP will cost you or VPS reseller do not suggest that management, you still have the way to add key to VPS.

I get stuck a while when managing the digitalocean VPS which is not allow to add key via control panel after Droplet (what they call VPS node)

First of all, we need a pair of public and private rsa key in laptop/pc

ssh-keygen -t rsa

Input required information with or without passphrase. Your key would be in ~/.ssh

Next, push it to VPS

cat ~/.ssh/id_rsa.pub | ssh USER@HOST "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

There is another shorthand to copy key to server is ssh-copy-id command. This is the last time you enter password to login to server :roll:

ssh-copy-id user@hostname

Here you go, try to ssh USER@HOST without input password, more convenient and faster 8-)