0

I have two boards that run linux os: the client runs raspberry os and the server runs ubuntu18.04. On the client, I generate an SSH key-pair using this command:

ssh-keygen

It prompts me to enter a file in which to save the key, I wrote my_key. After that, I pressed enter to fill empty the passphrase. It generates 2 files : /home/asd/.ssh/my_key and /home/asd/.ssh/my_key.pub

Using this command:

ssh-copy-id -i /home/asd/.ssh/my_key.pub client_username@hostname

I copied the public key on the server. I checked it, all the things were fine until now. When I tried to connect to the server, It prompts me to write the password. Why?

If I generate an SSH key-pair, and I fill the name file where to store to be default ( /home/asd/.ssh/id_rsa), I could connect to server without to ask me the password. Did I do something wrong when I chose my own name of the file where it is stored the key?

EDIT: To connect to the server, I used the next command:

ssh client_username@ip_server
Fredi
  • 49
  • 8
  • 2
    Since you used a non-default identity file name, you will need to specify it using `-i` on the `ssh` command line (or via a `.ssh/config` file). See for example [Specifying an IdentityFile with SSH](https://unix.stackexchange.com/questions/494483/specifying-an-identityfile-with-ssh) – steeldriver Mar 10 '22 at 13:05
  • @steeldriver yes, this is the problem. Thank you! – Fredi Mar 10 '22 at 13:13
  • 1
    DId you add and check on remote machine the key in `.ssh/authorized_keys` file? – Romeo Ninov Mar 10 '22 at 13:17

1 Answers1

1

Thank you @steeldriver, this is the response that solved my problem. Basically, when you create an SSH key-pair with non default name, to connect to the server using SSH, you should also provide the public key using the -i argument

ssh username_server@host_server_ip -i path_to_public_key
Fredi
  • 49
  • 8