$ ssh -T git@git.oschina.net
The authenticity of host 'git.oschina.net (218.60.114.30)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.oschina.net,218.60.114.30' (ECDSA) to the list of known hosts.
Permission denied (publickey).
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/git.oschina.net
如果执行ssh-add时提示"Could not open a connection to your authentication agent",可以现执行命令:
$ ssh-agent bash 来自
sudo git clone git@git.coding.net:huixisheng/layout.git
Cloning into 'layout'...
Permission denied (publickey).
fatal: Could not read from remote repository.
git配置多个ssh-key
生成key
ssh-keygen -t rsa -f ~/.ssh/git.oschina.net -C "469184346@qq.com"
直接输入回车
如果输入了密码
其他平台拷贝命令参考如何生成SSH key
粘贴刚才拷贝的内容
New SSH key
将新生成的key添加到ssh-agent中
测试是否配置成功
ssh -vT git@git.coding.net
是有结果返回的,看了debug信息都是正常的。执行如下(期间关闭了翻墙软件)
再次clone又可以了。没找到为何不行的根本原因
参考