2

I am currently trying to ssh into my hosting server I have created authorised keys and added the .pub to my hosting.

To save the keys so I don't have to keep doing ssh-add I ran the command ssh-add -K ~/.ssh/privatekey for each key. This worked perfectly for my MacBook which always connects, however this is not the case for my iMac.

With my iMac I can connect with my ssh key fine until I reboot the computer. Once I reboot I get prompted to enter a password. To stop this I also ran the -K command. Which added the identities and allowed me to connect, but unlike my MacBook I am still having to run ssh-add every time I want to connect to my hosting on my iMac. When my iMac asks for the password and, if try to enter the ssh passphrase I get access denied.

I have set up a config file, but nothing seems to work for my iMac. I am also running the latest version of macOS Sierra on both machines.

After searching for days on Google and talking with my hosting provider I keep getting the same answer to use ssh-add -K. It just seems strange that it is not working.

2 Answers 2

0

OpenSSH ssh-add does not have any -K switch. What are you trying to do? You should be good just with

ssh-add /path/to/your.key
2
  • Hi @Jakuje thanks for the reply. The -K is a mac only command which should add the ssh key to the Mac keychain so that the key is remembered on boot. I'm trying to get my iMac to remember my ssh identity so I don't have to do ssh-add each time I turn on my computer, like on my MacBook. For some reason my iMac forgets the identities of my keys every time I boot even when I do 'ssh-add' and 'ssh-add -K'. So when I try to ssh or deploy to my hosting provider it prompts me for a password until I run ssh-add.
    – Mat Teague
    Commented Oct 1, 2016 at 22:41
  • And how does it do that? Isn't there also some desktop application that could do the same from GUI?
    – Jakuje
    Commented Oct 2, 2016 at 5:59
0

I'm afraid I forgot about this question, sorry about that. Apparently after doing a lot of research it turns out that when Sierra was released this was an issue with that. So basically macOS doesn't remember anymore the ssh keys stored in the keychain with the -K command, like it did with older versions.

I know there are better ways but the easiest way I got around this was to add ssh-add -K and my keys in the ~/.bash_profile. This allowed my keys to be added to the agent on terminal start.

I know in terms of security this is not the best, but it was the easiest for me and also I couldn't get anything to work.

Of course I'm open to suggestions, if anyone comes across this and want's to add.

You must log in to answer this question.

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