1.在~/.ssh/ 下生成密钥
xx@xx:~/.ssh$ ssh-keygen -t rsa -f ~/.ssh/id_rsa_xx -C "Key for ssh stuff"
- 使用刚生成的密钥, 用ssh-copy-id 将服务器地址加入控制,如果需要制定端口号,在地址后面要指定端口号才可以,你可以基于一个密钥加入多个远程地址,只需要改变user_name@xxx.xx.xxx.xx即可
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 (编辑文件)