首先配置git:
$ git config --global user.name "xx"
$ git config --global user.email "xx@xx.com"
然后生成key:
$ ssh-keygen -t rsa -C “your-email@xx.com”-f xx
# -f是制定文件生成的位置和文件名,默认生成到 ~/.ssh文件夹下
注意:如果制定了文件名,一定要配置config文件,否则测试时候:ssh git@xx.com会连不上,提示Warning: Permanently added 'xx' (RSA) to the list of known hosts.
git@xx.com: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
新建文件,名为:config配置如下
Host git.xx.com
IdentityFile ~/.ssh/xx
User test
再次测试连接ssh git@xx.com,提示:
Welcome to GitLab, test!