1.在~/.ssh/ 下生成密鑰
xx@xx:~/.ssh$ ssh-keygen -t rsa -f ~/.ssh/id_rsa_xx -C "Key for ssh stuff"
- 使用剛生成的密鑰, 用ssh-copy-id 將服務器地址加入控制,如果需要制定端口號,在地址後面要指定端口號纔可以,你可以基於一個密鑰加入多個遠程地址,只需要改變[email protected]即可
xx@xx:~/.ssh$ ssh-copy-id -i id_rsa_xx.pub user_name@xxx.xx.xxx.xx
xx@xx:~/.ssh$ ssh-copy-id -i id_rsa_xx.pub user_name@xxx.xx.xxx.xx -p xx
3.爲了不輸入一長串的ssh 命令 在~/.ssh下創建一個config
xx@xx:~/.ssh$ touch config
xx@xx:~/.ssh$ chmod 700 config (修改權限)
xx@xx:~/.ssh$ vi config (編輯文件)