Forums

SSH without password login - Permission Denied

I am trying to create a passwordless login with SSH and I think I activated the wrong public key as the authentication key. I tried to add the other key to the authenticated_keys file but my permission is denied, I tried to delete and redo the process but again my permission is denied, then I tried with the ssh-copy-id as on the link attached and this also was denied. I have tried to change permissions with "chmod" but nothing works. What can I do now? I am new to SSH but I use rsync already to exchange data between devices but with a password login which I want to remove.

jeroencvlier@Jeroens-MBP ~ % ssh-copy-id jeroencvlier@ssh.pythonanywhere.com
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/jeroencvlier/.ssh/id_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
<<<<<<:>~ PythonAnywhere SSH. Help @ https://help.pythonanywhere.com/pages/SSHAccess
jeroencvlier@ssh.pythonanywhere.com's password: 
sh: 1: cannot create .ssh/authorized_keys: Permission denied

That's very strange. What do you see if you check the permissions on that file? For example, from Bash, run

ls  -l .ssh/authorized_keys

So when I run that command i get:

09:04 ~ $ ls  -l .ssh/authorized_keys
ls: cannot access '.ssh/authorized_keys': Permission denied

If i look at permissions for the folder after changing the command I get:

09:09 ~ $ ls -lha
drw-------  2 jeroencvlier registered_users 4.0K Jun 22 09:54 .ssh

if I change the initial command just to the ssh folder:

09:12 ~ $ ls -lha .ssh
?????????? ? ? ? ?            ? authorized_keys

and then to the authorised key folder again I get:

09:14 ~ $ ls  -lha .ssh/authorized_keys
ls: cannot access '.ssh/authorized_keys': Permission denied

You broke the permissions on your .ssh folder. Fix them with:

chmod 700 ~/.ssh

So now I can view the permissions but after adding the new key to the authenticated keys I am getting the following errors even after resetting and changing the permission of the files within the /.ssh folder to 600.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/jeroencvlier/.ssh/id_ed25519' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/Users/jeroencvlier/.ssh/id_ed25519": bad permissions

Where did you change the permissions? /Users/jeroencvlier/.ssh/id_ed25519 doesn't look like a standard PythonAnywhere path.

Ok I changed all permissions inside the /.ssh folder to 700 and deleted all the contents of it. Then redid the instructions here https://help.pythonanywhere.com/pages/SSHAccess/.

Everything now works smoothly. Thank you for your help

Glad you got that working!