git@osc私有库进行ssh -T提示Permission denied的问题 - konakona
konakona
Dream Afar.
konakona

git@osc私有库进行ssh -T提示Permission denied的问题

git@osc私有库进行ssh -T提示Permission denied的问题

平时在很多服务器进行Hook+Clone git@osc(private)配置不曾出现过这样的问题,决定把解决方案发布上来,日后若再有人遇到就可以顺手解决了!

出现这个问题的两大疑点就是:

  • Git版本过低,试试git –version 查看下,别低于1.7就行
  • 不同的git服务提供商(如github、oschina)所检测的公钥文件名不同而最终导致的Permission denied。

 

那么,先说下我在触发这个问题时的步骤:
0.git init
1.git remote add https://…………(我用的是https呢!)
2.设置全局用户名和邮箱
3.创建公钥->添加入git@osc公钥
4.使用ssh -T git@oschina.net 看是否Welcome我,结果一直要求输入密码(这个密码不管怎么输都是错的),错误提示为:“Permission denied, please try again.”,第三次后“Permission denied (publickey,password,keyboard-interactive).”
5.增加参数 -v ,查看报告日志:

# ssh -T -v git@git.oschina.net
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /root/.ssh/config
debug1: Applying options for git.oschina.net
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to git.oschina.net [112.124.6.106] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa_second type -1
debug1: identity file /root/.ssh/id_rsa_second-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'git.oschina.net' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa_second
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: password
git@git.oschina.net's password:

大家在自检的过程中,可以使用一个技巧,就是观察哪里开始要求输入密码了,往上看,最后检查的是哪个文件,应该就系这个文件不存在或不正确引起的Permission denied问题。

我这里已经高亮出来了,问题出在文件中无法提供正确的信息或不存在,所以才要求输入密码的。

那,还记不记得当初在官方教程的文中,生成的密码在哪吗?

# ls ~/.ssh/
config id_rsa id_rsa.pub known_hosts

是~/.ssh/id_rsa.pub这个文件,因为git@osc找不到这份文件(你可以看到上面它一直在找的是id_rsa_second)就报错了。我们改个名字就好了!

cp ~/.ssh/id_rsa ~/.ssh/id_rsa_second

再试试 ssh -T git@oschina.net 看看?没有问题了吧!

赞赏
#
首页      程序开发      Linux      git@osc私有库进行ssh -T提示Permission denied的问题

团哥

文章作者

继续玩我的CODE,让别人说去。 低调,就是这么自信。

发表回复

textsms
account_circle
email

konakona

git@osc私有库进行ssh -T提示Permission denied的问题
平时在很多服务器进行Hook+Clone git@osc(private)配置不曾出现过这样的问题,决定把解决方案发布上来,日后若再有人遇到就可以顺手解决了! 出现这个问题的两大疑点就是: Gi…
扫描二维码继续阅读
2014-08-16