0

i recently wanted to use ssh-keys instead of passwords for my server (Debian stretch). I am using an ubuntu subsystem on Windows (in case it matters).

I was following the top answer from this thread: Easiest way to copy ssh keys to another machine?

I did the following:

  1. Created a key with ssh-keygen and saved them at .ssh/xxx.pub
  2. ssh-copy-id -i .ssh/xxx.pub user@server.tld

After this step I got the following message:

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/xxx.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@tserver.tld's password:

Number of key(s) added: 1

I even checked on the server under ~/.ssh/authorized_keys there is the key.

But still when I try to connect to the server via:

ssh root@server.tld

I have to login with password.

Has someone an idea why this does not work?

muru
  • 207,228
nTro314
  • 11

1 Answers1

1

Okay so i had to specify the key i want to use with '-i'

e.g.

ssh -i ~/.ssh/mykey user@foo.bar

EDIT: You can also add a config file at ~/.ssh/config and add the following code

host * IdentityFile ~/.ssh/mykey

then you don't have to use the -i ... parameter

nTro314
  • 11