Passwordless SSH into MacOS Ventura doesn't work

I created a passwordless key using:

ssh-keygen -t ed25519


I then copied the public key to the server I'm trying to set up to access with this:

scp ~/.ssh/id_ed25519.pub [user]@[server]

(where "[user]" and "[server]" are replaced with the real names)


I then logged into that user at that server and added the id_ed25519.pub key to the .ssh/authorized_keys of that user:

cat id_ed25519.pub >> .ssh/authorized_keys


When I log out, and try to log back in again using "ssh [user]@[server]", I get:

Enter passphrase for key 'Users/[user]/.ssh/id_rsa':


If I just press return, I get the prompt:


([user]@[server]) Password:


So, didn't work. Any suggestions? Used to work fine, before I switched machines...

MacBook Pro 15″, OS X 10.11

Posted on Sep 1, 2023 12:40 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 1, 2023 1:09 PM

You can use this method to transfer the .pub key


ssh-copy-id -i ~/.ssh/id_ed25519.pub   user@remote.host 


Creating a passwordless ssh-keygen key


ssh-keygen -t ed25519 

 # Enter file in which to save the key (.../.ssh/id_ed25519):< accept default; just hit enter 

 # Enter passphrase (empty for no passphrase): < leave blank; just hit enter 

 # Enter same passphrase again:               < leave blank; just hit enter 


Why is ed25519 recommended:

https://medium.com/risan/upgrade-your-ssh-key-to-ed25519-c6e8d60d3c54


NOTE: I am using passwordless keys on Ventura, and on older macOS, OS X, Mac OS X versions going back to Snow Leopard 10.6 (maybe even before).


I also use the same keys on my work Linux hosted development and test systems. Plus AIX and Solaris.

Similar questions

10 replies
Question marked as Top-ranking reply

Sep 1, 2023 1:09 PM in response to pts

You can use this method to transfer the .pub key


ssh-copy-id -i ~/.ssh/id_ed25519.pub   user@remote.host 


Creating a passwordless ssh-keygen key


ssh-keygen -t ed25519 

 # Enter file in which to save the key (.../.ssh/id_ed25519):< accept default; just hit enter 

 # Enter passphrase (empty for no passphrase): < leave blank; just hit enter 

 # Enter same passphrase again:               < leave blank; just hit enter 


Why is ed25519 recommended:

https://medium.com/risan/upgrade-your-ssh-key-to-ed25519-c6e8d60d3c54


NOTE: I am using passwordless keys on Ventura, and on older macOS, OS X, Mac OS X versions going back to Snow Leopard 10.6 (maybe even before).


I also use the same keys on my work Linux hosted development and test systems. Plus AIX and Solaris.

Sep 1, 2023 1:22 PM in response to pts

What worked for me was:


eval `ssh-agent -s` [this I believe lets me simply confirm that the ssh agent is running]


ssh-add ~/.ssh/id_ed25519

response:

Identity added: /Users/[user]/.ssh/id_ed25519 ([user]@[local machine])


ssh-add ~/.ssh/id_rsa

response:

Enter passphrase for /Users/[user]/.ssh/id_rsa:

Bad passphrase, try again for /Users/[user]/.ssh/id_rsa:


...at which point it wouldn't accept any password I entered, except a blank return (???)


However, now it does not ask for passwords for ssh into the remote machine. I don't understand why, but I put this here in case it helps others who are similarly unclear what the problem might be.

Sep 1, 2023 2:00 PM in response to pts

pts wrote:

I don't follow this either. At that point that you refer to, when I simply press return (i.e., I don't enter any passphrase at all) then it skips to asking for the password for the remote machine (i.e., the very thing I'm trying to avoid). This is not at all intuitive... Why is it asking for a passphrase at that first step yet accepting nothing (except an empty return)?


Unix is not known for its consistency, nor its simplicity.


ssh works with a local private key, and a remote and public key, and often requires way too much manual setup for my own preference.


ssh can have a passphrase on the private key, and can encounter a password on the remote login when the remote public keys are not sent up correctly, when the local private or remote public key are not the expected format as expected by the local or remote system or the local private key or remote public key are not protected appropriately.


If a passphrase is set up on the private key, it will have to be specified on the ssh command, or the passphrase removed and the private key decrypted. I linked to how to remove the passphrase from the private key, if one has been set.


Differing from other implementations, macOS allows the ssh private key to be added to Keychain, as well:

https://apple.stackexchange.com/questions/48502/how-can-i-permanently-add-my-ssh-private-key-to-keychain-so-it-is-automatically#250572


When using ssh and it’s doing something unexpected, add -v, -vv, or -vvv to the ssh command to get some, or to get more, or to get extensive additional debugging information shown. Wading through that output takes time, amd some familiarity with how ssh works. But it is very useful for troubleshooting ssh connections.


DigitalOcean has an ssh intro here:

https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys

Sep 1, 2023 7:02 PM in response to pts

pts wrote:

I don't follow this either. At that point that you refer to, when I simply press return (i.e., I don't enter any passphrase at all) then it skips to asking for the password for the remote machine (i.e., the very thing I'm trying to avoid). This is not at all intuitive... Why is it asking for a passphrase at that first step yet accepting nothing (except an empty return)?

The passphrase is to protect the keys (encryption, I think). If you enter a password, it encrypts the key so you have to decrypt to use. If You don't enter a passphrase, you don't need to enter it to use the key.


It asks in case you want one. Unix tries to remove useless steps. The other method would be:

Do you want a passphrase?

Yes, ok, please enter.

Here are your protected keys.

No passphrase, here's your unprotect keys.


With the current implementation it asks for a passphrase, processes it if you enter one, and doesn't encrypt if you don't. Much more efficient.



Sep 1, 2023 12:58 PM in response to Barney-15E

I don't follow your answer. What is the "certificate" you are referring to? Is that the file 'Users/[user]/.ssh/id_rsa'? Also, how exactly does one "create a certificate without a password"?


More generally, exactly what are the steps required to set up passwordless ssh? Is there something I need to do on the server side? Is this problem just on my client side?

Sep 1, 2023 1:13 PM in response to MrHoffman

I don't follow this either. At that point that you refer to, when I simply press return (i.e., I don't enter any passphrase at all) then it skips to asking for the password for the remote machine (i.e., the very thing I'm trying to avoid). This is not at all intuitive... Why is it asking for a passphrase at that first step yet accepting nothing (except an empty return)?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Passwordless SSH into MacOS Ventura doesn't work

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.