Cloning repo

Before cloning he repo, make sure that you have generated the SSH key and then uploaded the content from the public key content to the github deploy keys section.

Step 1: Generating SSH keys

goto ~/.ssh folder in your server and generate the key.

$ ssh-keygen -t ed25519 -C "your_email@example.com" 
$ #ed25519 is the newest encryption
$ eval "$(ssh-agent -s)" #Start the ssh-agent in the background.
$ ssh-add ~/.ssh/id_ed25519 #Add your SSH private key to the ssh-agent. 
$ cat ~/.ssh/id_ed25519.pub
$ # Then select and copy the contents of the id_ed25519.pub file
$ # displayed in the terminal to your clipboard

Copy the above content to github and paste it in Deploy keys . You have to remember that, though the name of the ssh key generated via ssh-keygen can be anything,I have only find it working when the name of the key is id_rsa (There's a workaround though which will be explained later on).

Step 2: Testing connections

Sometimes you may get authentication failure error. If such case arises, test the connection first.

$ ssh -vT git@github.com

Note

If you get errors while cloning a public repo, then the most probable cause is, you don't have a id_rsa key. You should upload the key to the >profile/settings/SSH and GPG keys. This should enable you to clone the public repo.

Step 3: SSH config file

SSH config file makes it easy to connect.

~/.ssh/config


Host github.com
        User git
        Hostname github.com
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/github

Host anyname
        User root
        Hostname your_host_name
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/your_private_key

Last Updated: