Github SSH connection

51 阅读1分钟

Github

SSH connection 1, 2

  1. Check whether the SSH keys exist:

    $ cd ~/.ssh
    $ ls
    

    If there is no Private or Public key, may need to create one by:

    $ ssh-keygen -t rsa -C "your_email@example.com"
    

    id_rsa and id_rsa.pub will be public and private key respectively.

  2. To add a public key to GitHub account

    • Log in to GitHub account and click on profile picture.
    • From the dropdown menu, select "Settings".
    • On the settings page, click on the "SSH and GPG keys" button in the sidebar.
    • Click on the "New SSH key" button.
    • Enter any title for the key and copy the content of the id_rsa.pub file generated in the previous step and paste it into the "Key" input box.
    • click the "Add SSH key" button to add the public key to GitHub account.
  3. Connection

    • ssh -T git@github.com
    • If shows Hi username! You’ve successfully authenticated, but GitHub does not provide shell access, then it sucess.
    • For remote connection, may need to use in the format of git@github.com:XXX/XXX.git
    螢幕截圖 2024-05-28 下午11.38.19.png