免密登錄
- 在本地,生成rsa公私密鑰對(duì)
- 將公鑰文件scp到遠(yuǎn)程服務(wù)器
xx@xxx:~# ssh-keygen
xx@xxx:~# scp .ssh/id_rsa.pub yy@yyy:~
- 在遠(yuǎn)程服務(wù)器觉痛,將公鑰文件append到~/.ssh/authorzied_keys內(nèi)
yy@yyy:~# cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
別名登錄
- 在本地的
~/.ssh/config
文件中加入如下內(nèi)容
Host zzz
HostName aa.bb.cc.dd
Port 22
User root
IdentityFile ~/.ssh/id_rsa
上述參數(shù)含義
- Host 別名
- HostName 遠(yuǎn)程服務(wù)器的主機(jī)域名或ip
- Port 遠(yuǎn)程服務(wù)器使用的ssh端口號(hào)琴儿,默認(rèn)
22
- User 用戶名
- IdentityFile 上述免密登錄步驟中生成的私鑰文件路徑 默認(rèn)
~/.ssh/id_rsa
- 使用別名即可免密登錄
xx@xxx:~# ssh zzz