Generate SSH Public key
Most Git servers will choose to use the SSH public key for authorization. Each user in the system must provide a public key for authorization, and none will generate one. The process of generating the public key is similar on all operating systems. First make sure you have a public key. The SSH public key is stored by default in the directory under the account's home directory ~/.ssh
. Go inside and see:
$ cd ~/.ssh$ lsauthorized_keys2 ID_DSA known_hostsconfig id_dsa.pub
The key is to see if there is something
something.pub
a pair of files to use and to name, this something
is usually id_dsa
or id_rsa
. .pub
the file with the suffix is the public key, and the other file is the key. If you don't have these files, or simply .ssh
don't have a directory, you can ssh-keygen
create them. The program is provided by the SSH package on the LINUX/MAC system and is included in the Msysgit package on Windows:
$ ssh-keygengenerating public/private RSA key pair. Enter file in which to save the key (/USERS/SCHACON/.SSH/ID_RSA): Enter passphrase (empty for no passphrase): Enter same pas Sphrase again:your identification has been saved In/users/schacon/.ssh/id_rsa. Your public key have been saved in/users/schacon/.ssh/id_rsa.pub.the key fingerprint is:43:c5:5b:5f:b1:f1:50:43:ad:20:a6 : 92:6a:1f:9a:3a [email protected]
It asks you to confirm the location of the public key ( .ssh/id_rsa
), then it will let you repeat a password two times, if you do not want to use the public key to enter the password, you can leave blank.
Now, all users who have done this will have to give their public key to either you or the Git server's administrator (assuming the SSH service is set to use the public key mechanism). They only need to copy .pub
the contents of the file and send an email to the administrator. The public key looks roughly like this:
$ cat ~/.ssh/id_rsa.pubssh-rsa aaaab3nzac1yc2eaaaabiwaaaqeakloupkdhrfhy17sbrmtipnltgk9tjom/bwdsugpl+ nafzlhdtyw7hdi4yz5ew18jh4jw9jbhufrviqzm7xlelevf4h9lfx5qvkbpppswg0cda3pbv7kodj/mtyblwxfcr+ hao3fxritbqxix1nkhxphazsmcilq8v6rjsnaqwdsdmfvslvk/7xat3faojoasncm1q9x5+3v0ww68/ eifmb1zuufljqjkprrx88xypndvjynby6vw/pb0rwert/enmz+aw4ozpntpi89zpmvmluayrd2ce86z/il8b+gw3r3+ 1nkatmikjn2so1d01qratlmqvssbxnrrfi9wrf+m7q== [email protected]
For a tutorial on setting up the same SSH public key on multiple operating systems, you can review the SSH Public Key Wizard on GitHub: http://github.com/guides/providing-your-ssh-key
.
Git: Generate SSH Public key