添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to follow along the Upskillcourses.com web dev online course. In lesson 11 I'm supposed to link up cloud9 to github.

I'm trying to get the SSH key. But it's not working:

ec2-user:~/environment $ cat ~/.ssh/id_rsa.pub
cat: /home/ec2-user/.ssh/id_rsa.pub: No such file or directory

I've copied it exactly like the instructor did. I'll be honest in that I don't really know what I'm doing or how to fix. Seems like no one else is having this problem. Thanks for any help

SO is for programming questions, not questions about using or configuring Linux and its applications. Super User or Unix & Linux would be better places for questions like this. – Barmar Jul 13, 2018 at 23:07

Use ssh-keygen to create a default ssh key pair, for now without passphrase:

ssh-keygen -t rsa -C "MyEmailAddress" -f ~/.ssh/id_rsa -P ""

Then any ssh command will use by default that key.

ls -al ~/.ssh

Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following: id_xxxx.pub (ex: id_rsa.pub). If you don't have an existing public and private key pair, create one using this command:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

This creates a new ssh key, using the provided email as a label. When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location. At the prompt, type a secure passphrase.

If you see an existing public and private key pair listed that you would like to use to connect to GitHub, or once you are done with the above key generation step, you can add your SSH key to the ssh-agent with the following commands:

eval "$(ssh-agent -s)"

ssh-add ~/.ssh/id_rsa (Add -K option, if on MAC OS, as it will add the passphrase in your keychain when you add an ssh key to the ssh-agent.)

Source: https://docs.github.com/

This happened to me when I was simply in a directory other than the one where the SSH key was.

In order to fix this: you need to check the path to the directory where the SSH key was saved. Scroll up to where you created the key and you should see:

Your public key has been saved in /Users/userlocation/.ssh/id_rsa.pub

Now check your working directory:

If your working directory is different from the one that holds the SSH key, change the directory:

cd /Users/userlocation #find yours!

and then run the command (slightly changed):

cat .ssh/id_rsa.pub

This worked for me! (Remember to run ssh-keygen first!)

That is surprising. ssh-keygen by default writes the newly generated key to ~/.ssh/ in your home directory. ssh-keygen withour sudo should have worked. If it did not, either you did not post the full command or your home directory has files not owned by you (perhaps from using sudo when you should not have) – Andrey Bienkowski Nov 22 at 3:27

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.