SSH Keygen - biswajitsundara/gitdoc GitHub Wiki
SSH keys are a pair of public and private keys are used to authenticate/establish connection between client and remote machines.
- We need to generate the keys and keep the
private
key in our computer/laptop - And add the
public
key in the github. - So whenever our computer/laptop will try to connect to github cloud, it will allow.
$ ssh-keygen -t rsa -b 4096 -c "[email protected]"
t -- specifies the type of key to be created. The commonly used is "rsa" There is another type also "dsa" b -- specifies the number of bits in the key. In general 2048 is sufficient we can use 4096 c -- specifies the comment. The comment I have used my email id. When we execute the command it will ask for the pass phrase. The pass phrase is nothing but the password. Just hit enter to skip setting the password, else set the password.
$ eval $(ssh-agent -s)
- ssh-agent is a key manager for SSH.
- It holds your keys and certificates in memory unencrypted, and ready for use by ssh .
- It saves you from typing a passphrase every time you connect to a server.
$ ssh-add ~/.ssh/id_rsa
- The ssh-add command takes the private key password
- And adds it to the list maintained by ssh-agent
$ clip < ~/.ssh/id_rsa.pub
This will copy the public key to the clipboard
- Go to your remote git repo
https://github.com/username
- Profile -> Settings -> SSH & GPG Keys
- Click on 'New SSH Key
- Title =
the title of the key (e.g home_dell)
- Key =
Paste the key copied to clipboard
biswa@DESKTOP-8DO45Q1 MINGW64 ~ $ ssh-keygen -t rsa -b 4096 -C "[email protected]" Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/biswa/.ssh/id_rsa): Created directory '/c/Users/biswa/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/biswa/.ssh/id_rsa Your public key has been saved in /c/Users/biswa/.ssh/id_rsa.pub The key fingerprint is: SHA256:ILdWXE6NkeRdfgdfgdf645nghjghWb2Z4PD5Is [email protected] The key's randomart image is: +---[RSA 4096]----+ | oAo.o=CO | | .=+.+o+OO.. | | +.+o+=oo | | +=+= . | | +o=$. | | . = . | | E . | | | +----[SHA256]-----+ biswa@DESKTOP-8DO45Q1 MINGW64 ~ $ eval $(ssh-agent -s) Agent pid 926 biswa@DESKTOP-8DO45Q1 MINGW64 ~ $ ssh-add ~/.ssh/id_rsa Enter passphrase for /c/Users/biswa/.ssh/id_rsa: Identity added: /c/Users/biswa/.ssh/id_rsa ([email protected]) biswa@DESKTOP-8DO45Q1 MINGW64 ~ $ clip < ~/.ssh/id_rsa.pub