http://localhost:4000/title: Ubuntu设置ssh密钥登录 date: 2015-01-13 20:20:29 tags: - ubuntu - git - ssh categories: - ubuntu description: How to log in Ubuntu server with ssh key 生成keyfile: ```shell ssh-keygen -b 1024 -t dsa -N -f ~/.ssh/michael_dsa ``` 其中为你使用keyfile时的密码。 将生成私钥、公钥两个文件: michael_dsa michael_dsa.pub 上传keyfile: ```shell ssh-copy-id -i ~/.ssh/michael_dsa.pub michael@192.168.1.111 ``` 该命令自动将公钥复到用户的~/.ssh/authorized_keys文件中,完成后即可以密钥方式登录。 ##方法一:使用ssh-add ssh-add ~/.ssh/michael_dsa ##方法二:config中指定keyfile nano ~/.ssh/config Host myhost HostName 192.168.1.111 User username identityfile ~/.ssh/michael_dsa 设定config后,ssh登录、scp命令可简化为: ssh myhost scp test.txt myhost: