Easiest way to use ssh-key to login the remote server without password.

I use it all the time for ssh, sftp or rsync.

In Mac, please run the following command to install ssh-copy-id.

curl -L https://raw.githubusercontent.com/beautifulcode/ssh-copy-id-for-OSX/master/install.sh | sh

cd ~/.ssh

ssh-keygen and then type Enter for three times to generate id_rsa and id_rsa.pub

ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote_server_address

input the login password.

That’s all.

try ssh user@remote_server_address to see if it works.

I have used cat ~/.ssh/id_rsa.pub | ssh user@remote_server_address ‘cat >> .ssh/authorized_keys’ before. Sometimes it doesn’t work, but ssh-copy-id works well.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s