http://blog.csdn.net/chenxingzhen001/article/details/7740357



1.在本地机器上生成密码对

ssh-keygen -t rsa


查看一下ls
id_rsa  id_rsa.pub  known_hosts


2.将公钥拷到服务器端/root/.ssh下并安装


scp id_rsa.pub root@sg203:/root/.ssh


cat id_rsa.pub >> authorized_keys

chmod 600 authorized_keys



3.在服务器sg203上开启ssh服务的Pubkey认证功能,操作方法如下

vi /etc/ssh/sshd_config  

RSAAuthentication yes
PubkeyAuthentication yes

然后重启ssh服务  service sshd restart