• Home
  • LinuxGit
  • Automating Git for passwordless logins- Setup git key pairs and setup ~/.ssh/config file

Automating Git for passwordless logins- Setup git key pairs and setup ~/.ssh/config file

I’ve already posted about how to create key pairs fo SSH elsehere.

This is a short listing of the ~/.ssh/config file used for Git:

Host goob
     HostName buildbot1.snipanet.com
     User droidzone
     IdentityFile ~/.ssh/privatekey_goo
     ServerAliveInterval 30
     ServerAliveCountMax 120
Host goo
     HostName upload.goo.com
     User droidzone
     IdentityFile ~/.ssh/privatekey_goo
     ServerAliveInterval 120
     ServerAliveCountMax 120
     Port 2222
Host xda
     HostName build1.dev.xda-developers.com
     User droidzone
     IdentityFile ~/.ssh/xdamachine_key_openssh_pvt
     ServerAliveInterval 30
     ServerAliveCountMax 120
Host sf
     HostName shell.sourceforge.net
     User droidzone
     IdentityFile ~/.ssh/privatekey_sourceforge_ssh
     ServerAliveInterval 30
     ServerAliveCountMax 120
Host bitbucket.org
    IdentityFile ~/.ssh/id_rsa_bitbucket

 

Anatomy of a config file
A config file should be named ~/.ssh/config
The permissions of each key referred to by ssh should be restricted to user only, i.e chmod go=
The “Host” value is an alias
The “Hostname” value should be an ip or actual resolvable hostname
If Port is not 22, it should be specified in the file.

If the hostname is correct, you can login to sourceforge by typing: ssh sf
The username, hostname, key, port will be determined from the file.