Now Reading
Clone github repository on Linux machine using SSH

Clone github repository on Linux machine using SSH


This blog will help you setup github repository on Linux machine through SSH.

Step 1 :

Generate SSH key for the user



  • Login to the linux machine with the user where you want to configure. The user should have access to
  • Execute the below commands
Create directories :
mkdir -p /home/myuser/.ssh
Create authorized_keys file
touch /home/myuser/.ssh/authorized_keys
Add the user
useradd -d /home/myuser myuser
Set proper permissions:
chmod 700 /home/myuser/.ssh
chmod 644 /home/myuser/.ssh/authorized_keys
Set ownership:
chown -R myuser:myuser /home/myuser/*
Execute the below commands as root
vi /etc/ssh/sshd_config
Change :
PermitRootLogin prohibit-password to PermitRootLogin yes
PasswordAuthentication no to PasswordAuthentication yes
Restart ssh service:
sudo service ssh restart

Step 2 :

Add SSH key of the user to Github reporsitory

    • Copy the above generated SSH key (
    • Login to with the user you want to configure
    • In the upper-right corner of any page, click your profile photo, then click Settings.

    • In the user settings sidebar, click SSH and GPG keys.

    • Click New SSH key or Add SSH key.

See Also

  • In the “Title” field, add a descriptive label for the new key.
  • Paste your key into the “Key” field.
  • Click Add SSH key.
  • If prompted, confirm your GitHub password.


    Check for ssh connection

    ssh -vT
    If it succeeds you should get the below response
    Hi username! You've successfully authenticated...
    If the above command shows Permission denied, then follow the below steps
    • Open terminal
    • eval “$(ssh-agent -s)”
    • ssh-add ~/.ssh/id_rsa
    • ssh-add -l -E md5

    Again execute ssh -vT and you should get connected to the github server


    Clone any private/public repository on the machine you have configured now.

    git clone git@.git
View Comment (1)

Leave a Reply

Your email address will not be published.

Scroll To Top