SSh login without password [2 steps]

For instance, I want access to my CentOS server from my PC (Ubuntu) without input the password.

[What] SSH from Ubuntu to CentOS without passwd.

[How] Let the CentOS know the public rsa key of my Ubuntu.

Step 1. On Ubuntu: Create public/private RSA key pair.

ssh-keygen -t rsa 

Default, it will create two files: ~/.ssh/id_rsa and ~/.ssh/

Step 2. Copy of Ubuntu to ~/.ssh/authorized_keys on CentOS

scp ~/.ssh/  yourname@   
## ip of CentOS
## You need to input the passwd this time

## log in CentOS
ssh yourname@   # Input passwd of CentOS again    
cat ~/.ssh/ >> ~/.ssh/authorized_keys   # copy Ubuntu public rsa key to CentOS authorized  keys    
chmod 600 ~/.ssh/authorized_keys    

Finish. I can SSH to CentOS from my Ubuntu without passwd now.

ssh yourname@    # no need passwd

Just in the same way, I can generate and copy the public rsa key of CentOS to ~/.ssh/authorized_keys on Ubuntu to let CentOS log in Ubuntu without passwd.

Ming | 2015-04-11