Skip to content

krogrammer/GitHubDemo

Repository files navigation

GitHub Demo

Setting up SSH keys


Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username and personal access token at each visit.

SSH Key Types


Algorithm Public key Private key
ED25519 (preferred) id_ed25519.pub id_ed25519
RSA (at least 2048-bit key size) id_rsa.pub id_rsa
DSA (deprecated) id_dsa.pub id_dsa
ECDSA id_ecdsa.pub id_ecdsa

Check for existing SSH keys

  1. Open Terminal.

  2. Enter ls -al ~/.ssh to see if existing SSH keys are present:

    $ ls -la ~/.ssh
    # Lists the files in your .ssh directory, if they exist
  3. Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:

    • id_rsa.pub
    • id_ecdsa.pub
    • id_ed25519.pub

Generate SSH Key


  1. Open a terminal.

  2. Type ssh-keygen -t followed by the key type and an optional comment. This comment is included in the .pub file that's created. You may want to use an email address for the comment, but it is optional.

    For example, for ED25519:

    ssh-keygen -t ed25519 -C "<comment>"
  3. Press Enter. Output similar to the following is displayed:

    Generating public/private ed25519 key pair.
    Enter file in which to save the key (/home/user/.ssh/id_ed25519):
    
  4. Accept the suggested filename and directory, unless you want to save in a specific directory where you store other keys.

  5. Specify a passphrase, or leave empty to not be prompted for a password on every commit (less secure, but more convenient)

    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    
  6. A confirmation is displayed, including information about where your files are stored.

Add an SSH key to your GitLab account

To use SSH with GitLab, copy your public key to your GitLab account.

  1. Copy the contents of your public key file. You can do this manually or use a script. For example, to copy an ED25519 key to the clipboard:

    macOS:

    tr -d '\n' < ~/.ssh/id_ed25519.pub | pbcopy

    Linux (requires the xclip package):

    xclip -sel clip < ~/.ssh/id_ed25519.pub

    Git Bash on Windows:

    cat ~/.ssh/id_ed25519.pub | clip

    Replace id_ed25519.pub with your filename. For example, use id_rsa.pub for RSA.

  2. Sign in to GitHub.

  3. In the top right corner, select your avatar.

  4. Select Settings.

  5. From the left sidebar, select SSH and GPG Keys.

  6. In the top right, select New SSH key

  7. In the Key box, paste the contents of your public key. If you manually copied the key, make sure you copy the entire key, which starts with ssh-ed25519 or ssh-rsa, and may end with a comment.

  8. In the Title text box, type a description, like Work Laptop or Home Workstation.

  9. Select Add SSH key.

Proxy passing SSH

  1. Open the terminal.
  2. Change directories to where your ssh keys are stored.
    cd ~/.ssh/
  3. Create a config file and insert this into it.
    Host github.com
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ed25519
        PreferredAuthentications publickey
        PasswordAuthentication no
        IdentitiesOnly yes
        ProxyCommand /usr/bin/nc -x 127.0.0.1:3129 %h %p
    
  4. Save the file and exit

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages