Search code examples
sshgitolite

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


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 [email protected] 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:

[email protected]'s password:

Most interesting is when I'm changing my .git/config's url variable from git:poky to [email protected]:poky then everything works fine.

It seems more an ssh issue than a gitolite.

Could it be some environment variable?


Solution

  • 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 [email protected]: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.