Public key authentication not working

I followed the instructions here: SSH public key authentication - NixOS Wiki.

I am still prompted for a password and if I disable password authentication on the server I get this error:

Permission denied (publickey,keyboard-interactive)

Any thoughts?

That page lists two methods of placing your user’s key on the server, which did you use and how did you use it?

I did:

[user@clientmachine] $ ssh-keygen -f ~/.ssh/servermachine
[user@clientmachine] $ ssh-copy-id -i ~/.ssh/servermachine servermachine
[user@clientmachine] $ ssh -i ~/.ssh/servermachine servermachine

Thank you.

Did you get a password prompt? If you disabled password login before doing this, you won’t have a method of transferring your key via ssh.

No I didn’t disable password login first and was prompted for the password when copying the file. I turned off pwd auth to try to force the key auth which is when I got the error I mentioned. (So I turned it back on.)

Get BlueMail for Android

Odd! I assume you also are using the same username on both machines?

Does ssh give any more information on the server side, or if you increase verbosity (-vvv may be a bit too detailed)?

Indeed -vvv is my friend: more info, new mystery .

I get a series of errors like:

debug1: Trying private key: /home/biscotty/.ssh/id_rsa
debug3: no such identity: /home/biscotty/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /home/biscotty/.ssh/id_ecdsa
debug3: no such identity: /home/biscotty/.ssh/id_ecdsa: No such file or directory

dot, dot, dot.

I can see in my .ssh directory 2 files for the servermachine, one without extension and one with .pub (I think this is the one it wants). But no file with the specific name it seems to want.

Scroll to -i: ssh(1) - Linux manual page

In other words, your flag is somehow not set? Maybe try to configure your ~/.ssh/config to set the correct file instead.

I’m not quite sure what you mean.

Does anyone have any ideas about this?

Sorry, lost track of this thread; what I’m saying is, by using the -i flag on ssh you’re specifying the identity file (private key) to use. Clearly, ssh is ignoring your flag, otherwise it wouldn’t try to search for those other two files.

As an alternative to the command line flag, I suggest writing a ~/.ssh/config like this (while substituting things in <> for what you actually need):

# ~/.ssh/config
Host <servermachine>
HostName <servermachine.com>
User <user>
IdentityFile /home/user/.ssh/servermachine

The private key is in fact what you need according to the docs, but the public ket will work too, assuming the private one is in the same place as the public one with .pub removed.

1 Like

You are fantastic, thank you. There’s sure no need to apologize. Any effort you make is a gift of your time and I appreciate it.

Switching to NixOS reminds me of when I first started using Slackware. Since I moved away from Slackware I’ve done a lot less of editing configs, scripting, etc. In some ways this is a back-to-the-basics experience. And I’m really enjoying it.