5

I know there are many tutorials, including instructions on this forum but I find that SSH still asks me for a password.

Here is what I tried on the local machine:

ssh-keygen -t rsa                   #   Generate Key Pair, accepting all defaults
ssh-copy-id [email protected]        #   Copy to remote
ssh [email protected]                #   Still asks for password

I have also tried with a custom key:

ssh-keygen -t rsa -f ~/.ssh/test.rsa
ssh-copy-id -i ~/.ssh/test.rsa.pub [email protected]
ssh-add ~/.ssh/test.rsa
ssh -i ~/.ssh/test.rsa [email protected]

In the remote host, I have changed the privileges to authorized_keys:

chmod 600 authorized_keys

I have tried all the variations to copy the key to the remote server, but they all give me the same results, and the authorized_keys file has the same new key.

Many of the tutorials are several years old, and some are for linux, so I don’t know whether things should be different.

Is there an extra step I need to take to use SSH without a password?

I am on MacOS Catalina.

Update

I have turned on verbosity, and I get something like this:

debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /Users/me/.ssh/test.rsa RSA SHA256:…etc…
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/mark/.ssh/test.rsa RSA SHA256:…etc… explicit
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: keyboard-interactive

10
  • Is the .ssh directory set to 0700 on both machines? Is Public key authentication enabled on the target machine? To get more details connect with ssh -vvv ... and look for clues on why it doesn’t use publickey.
    – nohillside
    Commented Oct 22, 2020 at 4:59
  • @nohillside Yes, on both machines. I’m looking through the results of -vvv now.
    – Manngo
    Commented Oct 22, 2020 at 5:04
  • @nohillside I am looking through the results, and there seem to be some issues, but the file is 125 lines long, and I don’t know what I’m looking for. I do get a received packet type 51, which seems to mean a failure, and it then attempts alternative non-existent keys.
    – Manngo
    Commented Oct 22, 2020 at 5:52
  • I'm not too familiar which all the details, but maybe you can add the relevant part of the output to the question so others can throw in some ideas?
    – nohillside
    Commented Oct 22, 2020 at 5:56
  • 2
    I created a chat room so we can chat properly. You're getting a lot of mis-diagnosis and incorrect info. Let's get you sorted.
    – Allan
    Commented Oct 22, 2020 at 15:05

2 Answers 2

1

If you tell your config file about the setup it will work.

Open ~/.ssh/config

Add this:

Host whateverYouWannaCallIt
  Hostname      192.168.1.235
  User          me
  IdentityFile  ~/.ssh/id_rsa

Then you can do this:

ssh whateverYouWannaCallIt

I recommend when creating the ssh key, to not use a generic one and give it a name for the machine, so one key per computer. You don't want to use the same key for more than one machine... but that's what will happen if you keep using id_rsa.

So as step one, do something more like this:

ssh-keygen -t rsa -b 3072 -f ~/.ssh/theServersName.rsa
...
ssh-copy-id -i ~/.ssh/theServersName.rsa.pub [email protected]

Then point IdentityFile to the right place:

Host theServersName
  Hostname      192.168.1.235
  User          me
  IdentityFile  ~/.ssh/theServersName.rsa
1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – nohillside
    Commented Oct 22, 2020 at 15:29
0

This is not the final answer but another way to add the ssh-key to the remote host.

$ cat .ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys'
2
  • Thanks, I’ve already tried that. I get the same results.
    – Manngo
    Commented Oct 22, 2020 at 21:25
  • Can you check if the other machine has the ssh-key in the file .ssh/authorized_keys, there should the the string for the .ssh/id_rsa.pub copied before.
    – elulcao
    Commented Oct 24, 2020 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .