How to Configure github ssh on remote host

Configuring GitHub Account

For cloning and interacting with repositories, especially private ones, you'll need to configure your GitHub account settings and possibly generate SSH keys.
  1. SSH Keys: If you plan to use SSH for cloning and managing repositories (which is more secure), you'll need to generate an SSH key pair on your remote server and add the public key to your GitHub account.
    • Generate a new SSH key pair:
      ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
      Follow the prompts to complete the key generation, and ensure you use the email associated with your GitHub account.
    • Add the SSH key to your GitHub account:
      • Display the public key using cat ~/.ssh/id_rsa.pub, then copy it.
      • Go to GitHub, navigate to Settings → SSH and GPG keys → New SSH key, paste your key into the field, and save it.
  2. Git Configuration: Set your global username and email configuration on the server, which will be used for commits.
    git config --global user.name "Your Name" git config --global user.email "your_email@example.com"
These steps cover the basic setup required to clone a GitHub repository on a remote server and the initial configurations for your GitHub account. Remember, if you're working with private repositories or want an added layer of security, using SSH keys is recommended. Permissions: Make sure your ~/.ssh directory and its contents have strict permissions. GitHub requires your private keys to be accessible by you only:
chmod 700 ~/.ssh chmod 600 ~/.ssh/id_rsa chmod 644 ~/.ssh/id_rsa.pub
SSH-Agent: If you're using an SSH key with a passphrase, ensure your SSH agent is running and has your key loaded:
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_rsa
  1. Enter the following:
    $ ssh -T git@github.com
    # Attempts to ssh to GitHub
    
    You may see a warning like this:
    > The authenticity of host 'github.com (IP ADDRESS)' can't be established.
    > ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
    > Are you sure you want to continue connecting (yes/no)?
    
  2. Verify that the fingerprint in the message you see matches GitHub's public key fingerprint. If it does, then type yes:
    > Hi USERNAME! You've successfully authenticated, but GitHub does not
    > provide shell access.

Leave a Reply

Your email address will not be published. Required fields are marked *