1.生成密钥
ssh-keygen -t rsa
2.上传id_rsa.pub到服务器
cat ~/.ssh/id_rsa.pub | ssh username@yourhost 'cat >> .ssh/authorized_keys'
注意
要保证.ssh和authorized_keys都只有用户自己有写权限。否则验证无效。
chmod 700 -R .ssh
chmod 600 authorized_keys
3.配置别名.ssh/config
Host demo
HostName 1.1.1.1
User xl
Port 22
ServerAliveInterval 300
ServerAliveCountMax 36
4.连接
ssh demo