I have a remote server (Contabo), and a Host (my Dell computer). I have created a new sudo user laura instead of using root all the time, with:
adduser laura
usermod -aG sudo laura
I have generated SSH keys on my Dell computer with the following command:
ssh-keygen -t rsa -b 4096
The ssh-copy-id did not work, however I've used this command to send the public key newly generated, into my Contabo Server:
sudo scp id_rsa_contabo.pub laura@:/home/laura/.ssh/
Of course I have replaced with the IP of my Contabo server. I can see the public key inside my .ssh folder, which I insert into an authorized_keys file.
However, no matter what I do (and I've been trying for hours now), when I do this:
ssh laura@<IP>
With < IP > replaced by the IP address of my Contabo server, the system still asks me for a password!
What I've tried so far:
I made sure permissions were correct, as I read several articles on StackOF saying the .ssh folder should be set at 700 and the authorized_keys file should be at 600.
The naming is correct: authorized_keys with Z instead of S. Also, when I've generated a pair of key, I've named it id_rsa_contabo, and I did the following:
ssh-agent bash
ssh-add ~/.ssh/contabo_rsa
This is because my file does not match the default naming convention for keys (normally it’s id_rsa).
Trying to see what's going on in the var/log/auth : I can see bots trying to brute-force my server and failing, and I can also see myself connecting to the Contabo server with a password : nothing strange in this file to me.
Trying the following command:
ssh laura@161.97.167.13 -v
No error message, however my file id_rsa_contabo (the one in the authorized_keys) is not even read by the system. See my screenshot for the output of this command:
Trying the following command to force the system to use my newly generated key :
ssh -i id_rsa_contabo.pub laura@161.97.167.13
I have checked the content of /etc/ss/ssh_config and /etc/ss/sshd_config. I have the following in both:
RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile %h/.ssh/authorized_keys .ssh/authorized_keys2
.
Nothing seems to work. Please can a good samaritan help me? :(
It works now (after I came in the office the next day). I believe I forgot to restart the services with the following command...
systemctls restart ...