学习《Learning ROS for Robotics Programming - Second Edition》 时候从github下载源码报如下错误,后来发现是SSH key没有配置导致的问题。
wstool up -j8
error log如下:
[ros_book] Fetching git@github.com:AaronMR/Learning_ROS_for_Robotics_Programming_2nd_edition.git (version None) to /home/dev/lrrp_2nd_ws/src/ros_book
Cloning into '/home/dev/lrrp_2nd_ws/src/ros_book'...
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Exception caught during install: Error processing 'ros_book' : [ros_book] Checkout of git@github.com:AaronMR/Learning_ROS_for_Robotics_Programming_2nd_edition.git version None into /home/dev/lrrp_2nd_ws/src/ros_book failed.
ERROR in config: Error processing 'ros_book' : [ros_book] Checkout of git@github.com:AaronMR/Learning_ROS_for_Robotics_Programming_2nd_edition.git version None into /home/dev/lrrp_2nd_ws/src/ros_book failed.
配置SSH key大致过程如下:
1)Check that you are connecting to the correct server
ssh -vT git@github.com OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011 debug1: Reading configuration data /Users/you/.ssh/config debug1: Reading configuration data /etc/ssh_config debug1: Applying options for * debug1: Connecting to github.com [192.30.252.131] port 22.
如果输出如下“-1”,表示找不到文件,
ssh -vT git@github.com ... debug1: identity file /Users/you/.ssh/id_rsa type -1 debug1: identity file /Users/you/.ssh/id_rsa-cert type -1 debug1: identity file /Users/you/.ssh/id_dsa type -1 debug1: identity file /Users/you/.ssh/id_dsa-cert type -1 ... debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: /Users/you/.ssh/id_rsa debug1: Trying private key: /Users/you/.ssh/id_dsa debug1: No more authentication methods to try. Permission denied (publickey).
如果没有那么创建新的SSH key即可。
2)Generating a new SSH key
-
Open Terminal.
-
Paste the text below, substituting in your GitHub email address.
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
This creates a new ssh key, using the provided email as a label.
Generating public/private rsa key pair.
-
When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
-
At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".
Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again]
3)Adding your SSH key to the ssh-agent
-
Ensure ssh-agent is enabled:
# start the ssh-agent in the background eval "$(ssh-agent -s)" Agent pid 59566
-
Add your SSH key to the ssh-agent. If you used an existing SSH key rather than generating a new SSH key, you'll need to replace id_rsa in the command with the name of your existing private key file.
$ ssh-add ~/.ssh/id_rsa
-
Copy the SSH key to your clipboard.
If your SSH 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.
$ 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
Tip: If
xclip
isn't working, you can locate the hidden.ssh
folder, open the file in your favorite text editor, and copy it to your clipboard. -
In the top 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.