报错如下
[root@test1 learngit]# git push -u origin master
ssh: connect to host github.com port 22: Connection refused
fatal: The remote end hung up unexpectedly
公钥已经传到github上的话,分析原因为username没有指定对
cat /root/.gitconfig
[user]
name = test
email = test@test.com
cat /root/.ssh/config
Host github.com
User test
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
我的问题就是上面两个用户没有一样,改为一样后,测试成功
[root@test1 ~]# ssh -T git@github.com
The authenticity of host '[ssh.github.com]:443 ([192.30.253.123]:443)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[ssh.github.com]:443,[192.30.253.123]:443' (RSA) to the list of known hosts.