Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does git know who I am when I use ssh to log in?

Tags:

github

ssh

I set up SSH login for github using the following instructions, and although it works, I can't figure out why it works: https://help.github.com/articles/generating-ssh-keys/

My understanding of SSH is as follows: client creates a key pair, client gives public key to server, and when client wants to log in, he encrypts a message of server's choice using his private key to prove that he is really the client.

Now: I upload my public key XXX to Github. When I do "ssh -T [email protected]", Github has to know I am trying to log in as me, so that he can decrypt my message using XXX, right? So ssh has to send that information...but how does ssh know anything about Github, or what my username is? And what if I have multiple key pairs - which key would ssh use?

like image 620
user1299784 Avatar asked Jan 21 '16 20:01

user1299784


1 Answers

When you add your SSH public key to your GitHub account, you associate that key with your GitHub account.

By default, the command ssh -T [email protected] searches for id_dsa and id_rsa files. To confirm this, try ssh -T [email protected] -v.

If you have keys associated to different github accounts, you would have to specify with -i to use different accounts. ssh -T [email protected] -i /path/to/mykey

like image 94
Andrew F. Ly Avatar answered Sep 23 '22 06:09

Andrew F. Ly