I just upgraded from the free account to "Hacker". The current issue I'm dealing with is getting SSH to work using public key authentication, i.e. without a password. I've done this successfully many times on many other systems.
I have an existing SSH public/private key pair. I successfully did the ssh-copy-id
command and confirmed that ~/.ssh/authorized_keys
(on PythonAnywhere) has the public key listed. I also checked the permissions of ~/.ssh and contained files.
Performed on my local computer:
$ ssh-copy-id coops222@ssh.pythonanywhere.com ─╯
/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
coops222@ssh.pythonanywhere.com's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'coops222@ssh.pythonanywhere.com'"
and check to make sure that only the key(s) you wanted were added.
Performed in a PythonAnywhere Bash console:
18:55 ~ $ ls -ld ~/.ssh
drwx------ 2 coops222 registered_users 4096 Aug 13 18:53 /home/coops222/.ssh
18:55 ~ $ ls -l ~/.ssh
total 12
-rw------- 1 coops222 registered_users 413 Aug 13 19:20 authorized_keys
-rw------- 1 coops222 registered_users 2622 Aug 11 21:40 id_rsa
-rw-r--r-- 1 coops222 registered_users 582 Aug 11 21:40 id_rsa.pub
-rw-r--r-- 1 coops222 registered_users 666 Aug 11 21:45 known_hosts
I also checked that ~/.ssh/authorized_keys
contains the public key.
But when I try to connect it prompts for the password:
$ ssh -vvv coops222@ssh.pythonanywhere.com
<removed some of the debug "noise">
<<<<<<:>~ PythonAnywhere SSH. Help @ https://help.pythonanywhere.com/pages/SSHAccess
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/steve/.ssh/id_rsa RSA SHA256:tVLn5uPhftU4LP/1t2YDZiO+KefmiMgDoAFfMYPnrlM
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/steve/.ssh/id_ecdsa
debug3: no such identity: /Users/steve/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /Users/steve/.ssh/id_ecdsa_sk
debug3: no such identity: /Users/steve/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /Users/steve/.ssh/id_ed25519
debug3: no such identity: /Users/steve/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /Users/steve/.ssh/id_ed25519_sk
debug3: no such identity: /Users/steve/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /Users/steve/.ssh/id_xmss
debug3: no such identity: /Users/steve/.ssh/id_xmss: No such file or directory
debug1: Trying private key: /Users/steve/.ssh/id_dsa
debug3: no such identity: /Users/steve/.ssh/id_dsa: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
coops222@ssh.pythonanywhere.com's password:
So it tries to use the key, but fails with response 51 (?).
I noticed that /etc/sshd_config has "#PubkeyAuthentication yes" commented out. Does that mean it doesn't support key-based authentication in my VM? If so, how can it be enabled?
Sorry for the verbose post, but I'm trying to provide complete information.
Thanks in advance!