1
0
mirror of synced 2026-01-05 12:07:35 -05:00
Files
docs/data/reusables/gpg/copy-ssh-public-key.md
Nathan Miller 54e971a613 Update copy-ssh-public-key.md (#25911)
Co-authored-by: Steve Guntrip <stevecat@github.com>
Co-authored-by: Grace Park <gracepark@github.com>
2023-08-11 16:58:46 +00:00

2.1 KiB

  1. Copy the SSH public key to your clipboard.

    If your SSH public key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don't add any newlines or whitespace. {% mac %}

    $ pbcopy < ~/.ssh/id_{% ifversion ghae %}rsa{% else %}ed25519{% endif %}.pub
    # Copies the contents of the id_{% ifversion ghae %}rsa{% else %}ed25519{% endif %}.pub file to your clipboard
    

    {% tip %}

    Tip: If pbcopy isn't working, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.

    {% endtip %} {% endmac %} {% windows %}

    $ clip < ~/.ssh/id_{% ifversion ghae %}rsa{% else %}ed25519{% endif %}.pub
    # Copies the contents of the id_{% ifversion ghae %}rsa{% else %}ed25519{% endif %}.pub file to your clipboard
    

    {% note %}

    Notes:

    • With Windows Subsystem for Linux (WSL), you can use clip.exe. Otherwise if clip isn't working, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.
    • On newer versions of Windows that use the Windows Terminal, or anywhere else that uses the PowerShell command line, you may receive a ParseError stating that The '&lt;' operator is reserved for future use. In this case, the following alternative clip command should be used:
    $ cat ~/.ssh/id_{% ifversion ghae %}rsa{% else %}ed25519{% endif %}.pub | clip
    # Copies the contents of the id_{% ifversion ghae %}rsa{% else %}ed25519{% endif %}.pub file to your clipboard
    

    {% endnote %} {% endwindows %} {% linux %}

    $ cat ~/.ssh/id_{% ifversion ghae %}rsa{% else %}ed25519{% endif %}.pub
    # Then select and copy the contents of the id_{% ifversion ghae %}rsa{% else %}ed25519{% endif %}.pub file
    # displayed in the terminal to your clipboard
    

    {% tip %}

    Tip: Alternatively, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.

    {% endtip %} {% endlinux %}