ssh config is working from home, but not working f

2019-02-19 05:31发布

I could solve my problem, but I'm pretty curious why it isn't working the way it should be.

The problem:
In ~/.ssh/config there is an entry:

Host git
HostName git.myserver.com
User gitolite
Identityfile gitolite

After that in my home directory when I run: ssh git it returns this text (which is a normal thing):

PTY allocation request failed on channel 0

hello myname, this is gitolite@myserver.com running gitolite3 v3.4-3-g797a81f on git 1.7.2.5

 R W    myrepo1
 R W    myrepo2
 R W    .
 R W    .
 R W    .
Connection to git.myserver.com closed.

But when I'm running ssh git from my /opt/poky directory, it cannot authenticate me with my file... or I don't know what's the problem, but the result is:

gitolite@myserver.com's password:

Most interesting is when I'm changing my .git/config's url variable from git:poky to gitolite@git.myserver.com:poky then everything works fine.

It seems more an ssh issue than a gitolite.

Could it be some environment variable?

标签: ssh gitolite
1条回答
Deceive 欺骗
2楼-- · 2019-02-19 06:32

Your config file should contain, to be sure, the full path of your private/public key:

Identityfile /path/to/gitolite

Beside that, make sure $HOME is the same in both cases, and that you are running those commands with the same user id, to rule out any right access.

Most interesting is when I'm changing my .git/config's url variable from git:poky to gitolite@git.myserver.com:poky then everything works fine.

That means your public/private key (named ~/.ssh/gitolite(.pub)) is duplicated as ~/.ssh/id_rsa(.pub), which is the default name for those keys, as searched by ssh.

查看更多
登录 后发表回答