D
D
Dmitrii Solovev2015-04-12 16:02:38
linux
Dmitrii Solovev, 2015-04-12 16:02:38

How to use SSH authorization keys correctly?

In all manuals for using keys, they give an example with a standardly generated name "id_rsa". Login is working fine.
But when I create, for example, 5 keys for 5 different machines, copy them there via ssh-copy-id, naturally the key names differ from the standard "id_rsa", then autologin no longer occurs, since ssh looks for the same key by default:

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: ~/.ssh/id_rsa
debug1: Trying private key: ~/.ssh/id_dsa
debug1: Next authentication method: password

Here you have to add to the ssh -i .ssh/path_to_key command and hammer in your own alias for each server. Accordingly, if I want to use scp, for example, a new alias or mc is already needed there, and so I don’t really want to produce them.
How can you do it more correctly? So that ssh automatically binds the desired key to familiar names and searches for the desired name, and not the default one.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Melkij, 2015-04-12
@dimonnwc3

man ssh_config
Create ~/.ssh/config and fill in the host and IdentityFile matches. Here you can specify the port, username and other joys.

J
jcmvbkbc, 2015-04-12
@jcmvbkbc

Why do you need several private keys on one machine?

S
SagePtr, 2015-04-12
@SagePtr

You can use the same key for all machines. Further than the local machine, the private part of the key does not get anywhere, and if an attacker can steal it, then with the same result he will steal all five keys)

V
Vlad Zhivotnev, 2015-04-15
@inkvizitor68sl

ssh -i path/to/key [email protected]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question