How do I access my SSH public key?

前端 未结 19 942
星月不相逢
星月不相逢 2021-01-29 17:04

I\'ve just generated my RSA key pair, and I wanted to add that key to GitHub.

I tried cd id_rsa.pub and id_rsa.pub, but no luck. How can I acce

相关标签:
19条回答
  • 2021-01-29 17:34

    On terminal cat ~/.ssh/id_rsa.pub

    explanation

    1. cat is a standard Unix utility that reads files and prints output
    2. ~ Is your Home User path
    3. /.ssh - your hidden directory contains all your ssh certificates
    4. id_rsa.pub OR id_dsa.pub are RSA public keys, (the private key located on the client machine). the primary key for example can be used to enable cloning project from remote repository securely to your client end point.
    0 讨论(0)
  • 2021-01-29 17:35

    The following command will save the SSH key on the clipboard. You only need to paste at the desired location.

    cat ~/.ssh/id_rsa.pub | pbcopy
    
    0 讨论(0)
  • 2021-01-29 17:35

    On a Mac, you can do this to copy it to your clipboard (like cmd + c shortcut)
    cat ~/Desktop/ded.html | pbcopy
    pbcopy < ~/.ssh/id_rsa.pub

    and to paste pbpaste > ~Documents/id_rsa.txt

    or, use cmd + v shorcut to paste it somewhere else.

    ~/.ssh is the same path as /Users/macbook-username/.ssh
    You can use Print work directory: pwd command on terminal to get the path to your current directory.

    0 讨论(0)
  • 2021-01-29 17:36

    On Mac/unix and Windows:

    ssh-keygen then follow the prompts. It will ask you for a name to the file (say you call it pubkey, for example). Right away, you should have your key fingerprint and your key's randomart image visible to you.

    Then just use your favourite text editor and enter command vim pubkey.pub and it (your ssh-rsa key) should be there.

    Replace vim with emacs or whatever other editor you have/prefer.

    0 讨论(0)
  • 2021-01-29 17:37

    You may try to run the following command to show your RSA fingerprint:

    ssh-agent sh -c 'ssh-add; ssh-add -l'
    

    or public key:

    ssh-agent sh -c 'ssh-add; ssh-add -L'
    

    If you've the message: 'The agent has no identities.', then you've to generate your RSA key by ssh-keygen first.

    0 讨论(0)
  • 2021-01-29 17:38

    cat ~/.ssh/id_rsa.pub or cat ~/.ssh/id_dsa.pub

    You can list all the public keys you have by doing:

    $ ls ~/.ssh/*.pub

    0 讨论(0)
提交回复
热议问题