K
K
krll-k2014-08-12 13:14:49
linux
krll-k, 2014-08-12 13:14:49

How to establish ssh connection by keys?

I have a server that I access with a password. Next, I want to remove the need for password login. I am using ssh-keygen and it creates id_rsa and id_rsa.pub in ~/.ssh on the client. Next, what should I pass to the server, id_rsa or id_rsa.pub, in order to be able to connect to it?
Used ssh-copy-id to transfer to the server. Without parameters, it passes the private key, specifying the key i, it is possible to pass the public key to authorized_keys, passed it as well. Performed ssh-add on the client and on the server. I checked authorized_keys for the presence of both, everything you need is there. I performed ssh-keyscan on the client, everything is OK, and I still don’t understand what I’m doing wrong?
Please help clarify the situation!! Connection by key does not go, asks for a password. Tell me what to do after I do rm -rf ~/.ssh on the server and client?

Answer the question

In order to leave comments, you need to log in

8 answer(s)
S
s1dney, 2014-08-12
@krll-k

ssh-keygen #без аргументов, на все вопросы жать enter
ssh-copy-id [email protected] #user - это юзер на сервере server.com, а не локальный

If after that it asks for a password, then the most likely problems are:
- in the config /etc/ssh/sshd_config
- rights to ~/.ssh/authorized_keys or id_rsa, should be strictly 600
In the future, to find the problem, you can use ssh -vv [email protected] .com and read /var/log/secure log on server.com

S
Sergey Savostin, 2014-08-12
@savostin

And I am a patriot

V
Valentine, 2014-08-12
@vvpoloskin

The most accessible and working manual that I have seen.

N
Nazar Mokrinsky, 2014-08-12
@nazarpc

Very simple:
This will copy the key to the server, after that you can disable the password login and log in with the key.

E
Evgeny Rymarev, 2014-08-21
@Eugene_Rymarev

sshpass saves me.
I made a bunch of aliases on different servers and I don't suffer.

F
foboss, 2014-08-21
@foboss

Check the SELinux logs. It can cause the described special effect.
Treated by the team:
after handing over the keys.

R
rie, 2014-08-21
@rie

cat ~/.ssh/id_rsa.pub | ssh [email protected] "cat >> .ssh/authorized_keys"

R
raketur, 2015-12-27
@raketur

here is a video on the topic, everything is explained very clearly www.youtube.com/watch?v=5bF-DTxvvmQ

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question