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
  • 193,181
  • 53
  • 473
  • 722
nTro314
  • 11
  • 2

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
  • 2
  • Well, the default private key is `~/.ssh/id_rsa`. (There are other "default" filenames, depending on the algorithm used, but `id_rsa` is very common.) What's your key's filename? – PerlDuck May 29 '18 at 11:21
  • 1
    My key name was identity.pub, but i found the proper solution: You can add a config file in ~/.ssh/config and do host * IdentityFile ~/.ssh/mykey thanks tho – nTro314 May 29 '18 at 14:59
  • `.ssh/config` would have been my next suggestion but I wonder why `identity.pub` isn't found automatically. It's one of the default files. Although it's more _"ssh-v1"_-ey (I guess). – PerlDuck May 29 '18 at 15:03