0

I am trying to access my vps using SSH Key-Based Authentication. this is what i tried:

1.create a public and private key in Windows using PuTTYgen

2.copy the one line format of the public key to a this file /home/username/.ssh/authorised_keys this is how the key looks like:

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAxjoUKeoEWdpazINZ1WmEiierZ1eC/OtQ6r0MFBofBg3oSvzF0o3mqzJB2rklNAcFoiQ/MHB5nk7lLfb82Ny7np9vYXoprZinM68PSjfhNd20QfXRJfeTaKZqWtzv64r+zOPs3n32FEfSY5x5numk6YqZ1AjbwyU2/HhEUN35FzyjofZjCiR9BM5eaylf8yJ/fgHVoFBVuL7N5jsbPG6fP2ZEIGSBFH6DCN+HEpvySFzdgy2KkznRl0/o1dWc3FU8NaqZG+M1JZzEIjehEuaVwMFrIQxdHXoZCY7OJHHwWFOQCWhYScTh3PeOnvPnU6LYBLgAG+felrdQrho2My9jxw== rsa-key-20191225

3.sudo chmod 700 ~/.ssh

4.sudo chmod 600 ~/.ssh/authorized_keys

5.sudo chown -R $(whoami):$(whoami) ~/.ssh/

When I try to connect with private key loaded in PuTTY I get this error in the log: `

Dec 26 00:27:34 berbidserver sshd[29601]: debug1: Could not open authorized keys '/home/tarantula/.ssh/authorized_keys': No such file or directory
Dec 26 00:27:34 berbidserver sshd[29601]: debug1: restore_uid: 0/0
Dec 26 00:27:34 berbidserver sshd[29601]: debug1: temporarily_use_uid: 1001/1001 (e=0/0)
Dec 26 00:27:34 berbidserver sshd[29601]: debug1: trying public key file /home/tarantula/.ssh/authorized_keys2
Dec 26 00:27:34 berbidserver sshd[29601]: debug1: Could not open authorized keys '/home/tarantula/.ssh/authorized_keys2': No such file or directory

`

4
  • The error message is quite clear. Are you actually logging in through SSH with username tarantula ?
    – Kate
    Dec 25, 2019 at 21:15
  • yes, I followed this toturial: devanswers.co/putty-and-ssh-key-based-authentication. and enter tarantula as auto-login username Dec 25, 2019 at 21:24
  • You are using authorized_keys but SSH is looking for authorized_keys2 - that appears to be the core issue and is bizarre - are you running an ancient version of SSH, or has your config file been modified for the non-standard authorized_keys name (Maybe AuthorizedKeysFile in /etc/ssh/sshd_config)?o
    – davidgo
    Dec 26, 2019 at 8:25
  • @davidgo: the (upstream) default is to try both authorized_keys{,2} -- as clearly shown in the log; see the man page. This is true for all versions since at least 5.5 in 2010 and still the case for 9.0 in 2022. May 28, 2022 at 10:14

2 Answers 2

1

But did you SSH to the server with user tarantula when you created the folder ~/.ssh and copîed the files ? My guess is, you SSHed as root, that's why the files are not found in the home directory of user tarantula. They are most likely in /root.

If you don't want to grant user tarantula SSH rights, what you could do is:

  1. SSH to the server as root
  2. Then type: su - tarantula to log in as tarantula
  3. once you're logged in as tarantula, add the .ssh folder if it doesn't already exist, copy the files
2
  • I had a funny typo 'authorised_keys' while it actually should be 'authorized_keys'. typing here and seeing auto correction made me realize that. non-american people usually use authorise instead of authorize. I give you an up-vote because although your answer does not fix my problem but it actually provides good information. Dec 25, 2019 at 21:55
  • This is incorrect at least 2 ways. The log shows the correct user, not root. Also, the problem is the non-existance/nin-readability of the key.
    – davidgo
    Dec 26, 2019 at 8:19
0

simple really, you are using the english spelling of authorised, and ubuntu uses the american version authorized (with a Z)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .