git ssh登录

.ssh下创建config文件

其内容:

Host ip
IdentityFile ~/.ssh/私钥文件名
Port 22
User git服务器的账号,不是git账号名(私钥文件名才是git账号名)

注意: IdentityFile一定要写成绝对路径,否则无法找到私钥文件,ssh登录时用-i 来指定私钥位置,git仓库中git pull或push时则要将私钥放在仓库文件夹中,写成绝对路径就可以在任何位置使用ssh而不用指定私钥文件位置了。

如果ssh git@ip info出现下面的错误:

Bad owner or permissions on /home/mirandam/.ssh/config

This means you did not properly set the permissions on the config file. To fix:

# chmod 600 ~/.ssh/config
原文地址:https://www.cnblogs.com/zxpo/p/3873784.html