Now Reading
Clone github repository on Linux machine using SSH

Clone github repository on Linux machine using SSH

Views  
views
16

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

Step 1 :

Generate SSH key for the user

Note: DONOT EXECUTE THE BELOW COMMANDS WITH “sudo”

Ads

  • Login to the linux machine with the user where you want to configure. The user should have access to Github..com
  • 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 (id_rsa.pub)
    • Login to github.intel.com 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.

    Step3:

    Check for ssh connection

    ssh -vT git@github.com
    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 git@github.com and you should get connected to the github server

    Step4:

    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