How do I access my SSH public key?

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

    Open your id_dsa.pub or some_name.pub file with gedit and copy-paste the contents!

    Just use:

    ~/.ssh$ gedit some_name.pub
    
    0 讨论(0)
  • 2021-01-29 17:30

    Here's how I found mine on OS X:

    1. Open a terminal
    2. (You are in the home directory) cd .ssh (a hidden directory)
    3. pbcopy < id_rsa.pub (this copies it to the clipboard)

    If that doesn't work, do an ls and see what files are in there with a .pub extension.

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

    It can be found on this path (default path):

    /Users/john/.ssh
    

    john is your Mac username.

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

    Use:

    # sudo su
    # cd /home/user/.ssh
    .ssh# gedit id_rsa.pub
    

    Then copy the entire file without any spaces. Click your icon at the top right of the GitHub page, go to settings, and add ssh.

    Paste the copy into the space. It may prompt for your GitHub password. Enter it. Save.

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

    I use Git Bash for my Windows.

    $ eval $(ssh-agent -s) //activates the connection

    • some output

    $ ssh-add ~/.ssh/id_rsa //adds the identity

    • some other output

    $ clip < ~/.ssh/id_rsa.pub //THIS IS THE IMPORTANT ONE. This adds your key to your clipboard. Go back to GitHub and just paste it in, and voilá! You should be good to go.

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

    If you're using windows, the command is:

    type %userprofile%\.ssh\id_rsa.pub

    it should print the key (if you have one). You should copy the entire result. If none is present, then do:

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

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