SSH (Secure Shell) is used for more secure access between two parties. ssh is a password-less communication.There are two keys generated, private key & public key. The public key can be shared to other parties. Though the private key should be kept secret. If you know about cryptography then it would be easy to understand the concept fully. You can watch nasser hussian’s video to get some understanding. Though it's not required to fully understand the concept.
(Step confirmed working on Linux)
Open the terminal in root directory
Type
ls .ssh
in your terminal to check if there are any ssh present.
To create one type
ssh-keygen -t rsa -b 2048 -C ''Youremail@address''
It will prompt you to provide the location where the ssh file is to be created press enter to keep default location.
You can add a password for your file, to skip just press enter.
Now again if you again type command
ls .ssh
You may get something like this
id_rsa id_rsa.pub
The id_rsa.pub is the public key
cd .ssh && cat id_rsa.pub
to see the public key
Now copy the key and paste it into https://github.com/settings/ssh/new
Now select any repository that you want to clone locally.
You will find an option to select the ssh link for the repo
git@github.com:organization-name/respo-name.git
The next steps are
git clone git@github.com:organization-name/respo-name.git
(be sure to use the device from which the ssh keys was generated)
Now you have successfully set up ssh.
What if you already have repository in your local using http
First open the terminal from the root directory of your repository.
You could check your remote git url using
git remote -v
Now to set the ssh url can do
git remote set-url origin git@github.com:organization-name/respo-name.git
Now after this you could do all push pull normally as you would do.
Top comments (0)