O
O
Oleg Biryuk2020-06-17 16:58:23
linux
Oleg Biryuk, 2020-06-17 16:58:23

When connecting via SSH, it constantly asks for a password, how to fix it?

Copied the keys to the server using ssh-copy-id. Everything worked fine. Then I changed the umask in the ~/.profile file from 022 to 002. And the login to the server without entering a password stopped working. I thought that the problem was with user rights to the ~/.ssh folder and gave it permissions 770, and authorized_keys 660. It did not help. Deleted the ~/.ssh folder and copied the keys again using ssh-copy-id. The keys are successfully copied, but when entering the server, the password is still requested. Where to dig?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
O
Oleg Biryuk, 2020-06-19
@OleG2e

Issue resolved. It turned out to be the wrong rights to the user's directory. They were 775, and after setting them to 700, authorization by key worked. Thank you all for your support

D
Dmitry, 2020-06-17
@Tabletko

~/.ssh should have permissions 700 and 600 for directories and files, respectively

C
CityCat4, 2020-06-17
@CityCat4

Start the server manually with the -vvv key and try to connect - the server should write on the console how it chose the authentication order and what it doesn't like. There are usually two problems - wrong rights and wrong owner.

S
Saboteur, 2020-06-17
@saboteur_kiev

ssh [email protected] -vvv
and see the detailed connection log.
The rights should be 600 on the file with the private key on the local computer.
on remote it is not obligatory so to limit everything.

R
rostislav-zp, 2020-06-18
@rostislav-zp

let's say you are already rooted on the server. create a new user with root rights. in my case, rost
sudo adduser rost
sudo usermod -aG sudo rost
su rost
mkdir ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
(your key)
chmod 600 ~/.ssh/authorized_keys
exit
sudo nano /etc/ssh/sshd_config
(PasswordAuthentication no
PubkeyAuthentication yes
ChallengeResponseAuthentication no)
and in general here is an excellent guide, like many others of the same provider https://www.digitalocean.com/ community/tutorials/i...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question