ssh key disable - yaokun123/php-wiki GitHub Wiki

gitlab的ssh key不生效的问题

在用 gitlab 的管理代码时发现一个问题:如果用 http 协议,每次 push 的时候都需要输入用户名和密码,如果 用 ssh 协议,先要生成公钥:

ssh-keygen -t rsa -C 'jiqiang@xxx'​

然后把生成的公钥文件 id_rsa.pub​ 中的内容添加到 gitlab 的『SSH Keys』 接着用 ssh 协议 clone​ 项目,push 的时候还是会报验证错误。 找了一下,解决方案如下:

执行 ssh -T [email protected] (注: git 是我 gitlab 服务用户,@后面的那个地址是我gitlab 的服务器域名)​

主要原因是在 gitlab 机器上 git 用户是有 shell 的:

git:x:497:497::/var/opt/gitlab:/bin/sh​

ssh -T : Disable pseudo-tty allocation.

具体的解释,就不啰嗦了,stackoverflow 说的挺清楚的:

http://stackoverflow.com/questions/17900760/what-is-pseudo-tty-allocation-ssh-and-github​

http://stackoverflow.com/questions/10330678/gitolite-pty-allocation-request-failed-on-channel-0

更多访问:http://blog.sina.cn/dpool/blog/s/blog_70b9a0e90102wi8y.html