首先要在本地创建公钥,在命令行中输入
ssh-keygen -t rsa -C "xxxxxxxx@xxx.com"
~/.ssh/目录下会有生成的公钥id_rsa.pub,将其中的内容复制到服务器同目录下的authorized_keys中,保存。
然后打开/etc/ssh/sshd_config,确认以下内容没有被注释
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
重启sshd,service sshd restart