makansij
makansij

Reputation: 9865

Does github mandate that you use “git” as username when ssh-ing?

I’m trying to ssh to github.com, but I’m having trouble connecting when I use a different username other than “git”, and I’m not totally sure why. I have an ~/.ssh/config file to tell git which private rsa key to use when I am connecting to git. And, my knowledge of .ssh/config files is the following:

Let’s say I have this in my ~/.ssh/config file:

Host something.github.com
    Hostname github.com
    User someuser
    IdentityFile ~/desired/private_key

I always thought that this means whenever I do [email protected], it will ALWAYS use the file ~/desired/private_key to connect. Firstly – is my understanding of that correct?

Second, I have the following in my ~/.ssh/config file:

# for work
Host my-company.github.com
    Hostname github.com
    User git
    IdentityFile ~/.ssh/id_rsa_veritone 

# also for work, but using my username
Host company.github.com
    Hostname github.com
    User employee
    IdentityFile ~/.ssh/id_rsa_veritone

The my-company.github.com works, but company.github.com does NOT:

08:20 $ ssh -T [email protected] 
Hi employee! You've successfully authenticated, but GitHub does not provide shell access.

08:20 $ ssh -T [email protected] 
Permission denied (publickey).

Is this the expected behavior? If so, then does git mandate that I use git as my username when I ssh? If not, then what could be the issue that one of these does not work?

Upvotes: 0

Views: 36

Answers (1)

makansij
makansij

Reputation: 9865

YOu always have to use the git user. from https://help.github.com/articles/error-permission-denied-publickey/:

"All connections, including those for remote URLs, must be made as the "git" user. If you try to connect with your GitHub username, it will fail:"

Upvotes: 1

Related Questions