ssh config is working from home, but not working from another directory

∥☆過路亽.° 提交于 2019-12-01 08:05:34

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/16897433/ssh-config-is-working-from-home-but-not-working-from-another-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!