Forums

SSH - Permission Denied

Hi, I created an SSH key and pasted it into Github (using 'ssh-keygen', then '~/.ssh/id_rsa.pub'). When I tried uploading my Github files to PythonAnywhere (using git clone git@github.com:myusername/myproject.git), I got 'permission denied'. I thought that I might have incorrectly copied the key to Github (maybe I didn't cut and paste the whole key), so I tried to create a new key again using 'ssh-keygen'. These seemed to work fine. When I tried to get the key (using '~/.ssh/id_rsa.pub'), I am getting 'permission denied'. Can you please help me understand why I got the 'permission denied' when trying to upload from Github and why I am getting the same 'perrmission denied' when trying to get my key? Thank you.

I'm not sure what you tried to do when you did what you described "When I tried uploading my Github files to PythonAnywhere (using git clone git@github.com:myusername/myproject.git)"

I just typed in that command 'git clone git@github.com:myusername/myproject.git and substituted in my git hub user name and git hub project name. Then, it came back with 'permission denied'. If I try to create a new key, I get the same 'permission denied'.

Also, when I originally created the key and it asked me for a passphrase, I pressed 'enter', rather than providing a phrase. Then, when I used the git clone command to try to upload my files from GitHub to PythonAnywhere and it asked me for a passphrase, I pressed enter. Maybe I needed to give it a phrase for the passphrase.

In your first post you said:

When I tried to get the key (using '~/.ssh/id_rsa.pub'), I am getting 'permission denied'

Were you just running ~/.ssh/id_rsa.pub as a command in Bash? That file is a text file containing your key rather than a command file, so the way to examine its contents so that you can copy/paste them into GitHub is to use the cat command:

cat ~/.ssh/id_rsa.pub

Thank you. I am still getting 'permission denied'. I made a new key and copied it into Github. When I run 'git clone git@github.com:user_name/project_name.git', I get 'permission denied (publickey), could not read from remote repository. Please make sure you have the correct access rights and the repository exists.' If it helps, I get no response when I enter any of the following commands after this: 'ssh -T git@github.com', 'ssh-vT git@github.com', 'ping github.com', or 'ping google.com'.

Did you create that url by hand or copied it from github?

I did it by hand and then just tried to do it by copying from github. I still get 'permission denied (publickey), could not read from remote repository. Please make sure you have the correct access rights and the repository exists." It asks me for my passphrase three times before I get this message. I am carefully typing in the same psssphrase that I gave when I made the key.

It work now! It was using an old key that was in the same folder as the new key.

I'd advice against using a passphrase with an ssh key