I have configured ssh keys for github. I have multiple ssh keys configured already. I need to add new ssh keys for bitbucket. But it does not seem to be working.

How do i restart sshd in OSX Lion?


How do i restart sshd in OSX Lion?

You probably know this already, but I'll say to be complete: if you kill sshd processes you'll terminate active SSH sessions to the machine. The sshd daemon provides ssh access to your machine. It handles incoming ssh connections. Not outbound connections.

If sshd is really what you mean then...

Before you restart it, try sending it a SIGHUP signal so it re-reads all of its configuration. You can do that with

ps -ef | grep sshd | awk {'print $2'} | sudo xargs kill -HUP

If you really want to kill all the sshd process on the machine:

ps -ef | grep sshd | awk {'print $2'} | sudo xargs kill -KILL

But try this stuff below first!

All that being said: if you're looking for keys for outbound sessions from the machine to be refreshed, killing sshd processes won't help you. What you really want to do is to add the new keys to the ssh-agent process with ssh-add -- that is usually sufficient to get new keys to be known to the agent.

The ssh-agent process handles all keyfile-based authentication for you. It's started automatically by Lion for each logged in user and it even integrates with Keychain.

If your new keyfile is ~/.ssh/bitbucket you would add it like so:

ssh-add ~/.ssh/bitbucket

Now the key would be available to new ssh sessions initiated from the terminal. No need to kill or restart anything.

You must log in to answer this question.

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