免密登录
- 在本地,生成rsa公私密钥对
- 将公钥文件scp到远程服务器
xx@xxx:~# ssh-keygen
xx@xxx:~# scp .ssh/id_rsa.pub yy@yyy:~
- 在远程服务器,将公钥文件append到~/.ssh/authorzied_keys内
yy@yyy:~# cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
别名登录
- 在本地的
~/.ssh/config
文件中加入如下内容
Host zzz
HostName aa.bb.cc.dd
Port 22
User root
IdentityFile ~/.ssh/id_rsa
上述参数含义
- Host 别名
- HostName 远程服务器的主机域名或ip
- Port 远程服务器使用的ssh端口号,默认
22
- User 用户名
- IdentityFile 上述免密登录步骤中生成的私钥文件路径 默认
~/.ssh/id_rsa
- 使用别名即可免密登录
xx@xxx:~# ssh zzz
网友评论