本文为原创博客,转载请注明出处:https://blog.csdn.net/q_z_r_s
机器感知 一个专注于SLAM、三维重建、机器视觉等相关技术文章分享的公众号 |
Checking for existing SSH keys
$ ls -al ~/.ssh
Generating a new SSH key
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Generating public/private rsa key pair.
Enter a file in which to save the key (/home/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
Adding your SSH key to the ssh-agent
- Start the ssh-agent in the background.
$ eval "$(ssh-agent -s)"
- Add your SSH private key to the ssh-agent. If you created your key with a different name,
or if you are adding an existing key that has a different name,
replace id_rsa in the command with the name of your private key file.
$ ssh-add ~/.ssh/id_rsa
Adding a new SSH key to your GitHub account
- Copy the SSH key to your clipboard.
$ sudo apt-get install xclip
# Downloads and installs xclip. If you don't have `apt-get`,
# you might need to use another installer (like `yum`)
$ xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
- In the upper-right corner of any page, click your profile photo, then click Settings.
- In the user settings sidebar, click SSH and GPG keys.
- Click New SSH key or Add SSH key.
- In the “Title” field, add a descriptive label for the new key. For example, if you’re using a personal Mac, you might call this key “Personal MacBook Air”.
- Paste your key into the “Key” field.
- Click Add SSH key.
- If prompted, confirm your GitHub password.
Testing your SSH connection
$ ssh -T git@github.com
# Attempts to ssh to GitHub
Adding or changing a passphrase
$ ssh-keygen -p
# Start the SSH key creation process
Enter file in which the key is (/Users/you/.ssh/id_rsa): [Hit enter]
Key has comment '/Users/you/.ssh/id_rsa'
Enter new passphrase (empty for no passphrase): [Type new passphrase]
Enter same passphrase again: [One more time for luck]
Your identification has been saved with the new passphrase.