创建密钥
ssh-keygen -t rsa
1、用户目录下新建.ssh/authorized_keys
mkdir .ssh #创建隐藏目录
#修改文件访问权限
chmod 700 .ssh
cd .ssh
vim authorized_keys
#修改文件访问权限
chmod 644 authorized_keys
2、配置/etc/ssh/sshd-config
vim /etc/ssh/sshd-config
Protocol 2 //仅使用ssh2
#设置是否限制root登录
PermitRootLogin no
ServerKeyBits 1024 #位数
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PermitEmptyPasswords no //限制空密码登录
PasswordAuthentication no//限制密码登录
PasswordAuthentication no//限制密码登录
3、重启sshd
service sshd restart