How do I configure SSH on OS X?

21

14

I'm trying to SSH from one Mac running OS X 10.6 to another. Seems to work fine via a password, but I can't get it to use a RSA key instead. Where is the ssh configuration file on OS X and what is the command to reload SSH?

Update

What I'm asking is how to configured advanced options. For example, on Ubuntu there is a ssh config file at /etc/ssh/sshd_config and if you do something like change the port or disable password authentication for a particular user (PasswordAuthentication no) you need to run /etc/init.d/ssh reload to reload the config. I didn't see that file on OS X, so was just wondering where it was. I am aware of the ~/.ssh ~/.ssh/authorized_keys and ``~/.ssh/config`

cwd

Posted 2011-12-03T19:45:25.247

Reputation: 13 508

By ssh configuration file, do you mean ~/.ssh/authorized_keys, the same file as on any platform? – Daniel Beck – 2011-12-03T20:10:47.697

1And why do you want to reload SSH? Doesn't it suffice to update the authorized_keys file for the user account you want to log in as? Please describe the problem you're facing in more detail. – Daniel Beck – 2011-12-03T20:15:50.340

1On Ubuntu there is a ssh config file at /etc/ssh/sshd_config and if you do something like change the port or disable password authentication for a particular user (PasswordAuthentication no) you need to run /etc/init.d/ssh reload to reload the config. I didn't see that file on OS X, so was just wondering where it was. I am aware of the ~/.ssh ~/.ssh/authorized_keys and ``~/.ssh/config` – cwd – 2011-12-04T00:30:22.923

Answers

35

The SSHD configuration is stored in

/private/etc/ssh/sshd_config

To stop and start SSHD:

sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd

mark

Posted 2011-12-03T19:45:25.247

Reputation: 521

3Not sure if this is just because of how my machine is setup or not, but as of OS X Mavericks the sshd service I needed to specify in launchctl is org.openbsd.ssh-agent – Dan Herbert – 2014-07-24T12:18:38.533

4I think you mean /private/etc/ssh/sshd_config and /private/etc/ssh/ssh_config. Don't forget the ssh directory. – voutasaurus – 2016-01-14T21:12:49.350

my settings: alias restartsshd='sudo launchctl stop com.openssh.ssh-agent; sudo launchctl start com.openssh.ssh-agent;' Get the service name by using launchctl list | grep openssh – Marslo – 2018-01-30T14:30:56.240

3

You can restart SSH somewhere in the sharing dialogs, but you don't have to. According to the man page on apple.com keys go to the ~/.ssh/authorized_keys file.

artistoex

Posted 2011-12-03T19:45:25.247

Reputation: 3 353

3

In OS X El Capitan 10.11, sshd_config is in /private/etc/ssh/sshd_config (same as /etc/ssh/sshd_config)

Peter Tseng

Posted 2011-12-03T19:45:25.247

Reputation: 311

0

Note that in newer OS X releases it is not enough to enable "Remote login" in System Preferences > Sharing to allow SSH connections to your Mac if the firewall is running.

Go to System Preferences > Security & Privacy > Firewall > Firewall Options. You will see that "Remote login" is listed on the top and incoming connections are allowed. Contrary to expectations this is not sufficient. You have to add another program called /usr/libexec/sshd-keygen-wrapper as well (locate its directory with [Shift-Cmd-G]), using the [+] button and then set "Allow incoming connections" for it. Now you'll be able to SSH into your machine.

Laryx Decidua

Posted 2011-12-03T19:45:25.247

Reputation: 193