How do I access my SSH public key?

前端 未结 19 910
星月不相逢
星月不相逢 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:39

    Copy the key to your clipboard.

    $ pbcopy < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard
    

    Warning: it's important to copy the key exactly without adding newlines or whitespace. Thankfully the pbcopy command makes it easy to perform this setup perfectly.

    and paste it wherever you need.

    More details on the process, check: Generating SSH Keys.

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

    After you generate your SSH key you can do:

    cat .ssh/id_rsa.pub |pbcopy
    

    which will copy your ssh key into your clipboard.

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

    In UBUNTU +18.04

             ssh-keygen -o -t rsa -b 4096 -C "email@example.com" 
    

    And After that Just Copy And Paste

             cat ~/.ssh/id_rsa.pub 
    

    or

             cat ~/.ssh/id_dsa.pub
    
    0 讨论(0)
  • 2021-01-29 17:39

    If you only have your private key available, you can generate the public key from it:

    ssh-keygen -y
    

    or

    ssh-keygen -y -f path/to/private_key
    
    0 讨论(0)
  • 2021-01-29 17:45

    Open terminal nano ~/.ssh/id_rsa.pub

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

    If you are using Windows PowerShell, the easiest way is to:

    cat ~/.ssh/id_<key-type-here>.pub | clip
    

    That will copy the key to your clipboard for easy pasting.

    So, in my instance, I use ed25519 since RSA is now fairly hackable:

    cat ~/.ssh/id_ed25519.pub | clip
    

    Because I find myself doing this a lot, I created a function and set a simple alias I could remember in my PowerShell profile (learn more about PowerShell profiles here. Just add this to your Microsoft.PowerShell_profile.ps1:

    function Copy-SSHKey {
        Get-Content ~/.ssh/id_ed25519.pub | clip
    }
    
    Set_Alias -Name sshkey -Value Copy-SSHKey
    

    Then, in a PowerShell console, run . $profile to load the functions. Then from now on all you will need to do is run sshkey, and then paste the key into wherever you need via the clipboard.

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