Git insists on asking me for my user name

ssh
github
git

#1

This worked okay:
rhedin:~/workspace (master) eval (ssh-agent -s)
Agent pid 47088

And this worked okay:
rhedin:~/workspace (master) $ ssh-add ~/.ssh/id_rsa
Identity added: /home/ubuntu/.ssh/id_rsa (/home/ubuntu/.ssh/id_rsa)

But still:
rhedin:~/workspace (master) $ git push origin master
Username for ‘https://github.com’: ^C

My ~/.ssh/config file looks like this:
rhedin:~/workspace (master) $ cat ~/.ssh/config
HashKnownHosts no

Host github.com
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes
UserKnownHostsFile /dev/null
StrictHostKeyChecking no

Host bitbucket.org
Hostname bitbucket.org
IdentitiesOnly yes
UserKnownHostsFile /dev/null
StrictHostKeyChecking norhedin:~/workspace (master) $

Do you know why it insists on asking me for my username and password?


#2

If you run git remote -v, you’ll probably see something like this:

origin  https://github.com/username/repository.git (fetch)
origin  https://github.com/username/repository.git (push)

The problem here is that because your remotes use HTTP(S) rather than SSH, it’s completely ignoring all of your SSH settings. To fix this, go to your GitHub repository, click on Clone or Download, click the Use SSH link at the top right of the popup, and copy the link that should be in the format, git@github.com:username/repository.git. Then, in the Cloud9 terminal, run git remote set-url origin <paste URL here>, and when you run git remote -v, you should see something like the following:

origin  git@github.com:username/repository.git (fetch)
origin  git@github.com:username/repository.git (push)

Now, try pushing with the normal git push origin master. This time, your SSH settings should be respected, and it shouldn’t ask you for your username.


#3

You’re right. That’s it!

I haven’t tried it yet, but I’m sure that’s it. Bless you.


#4

Yup. It worked! Thanks.