# SSH on macOS

## Restart SSH

```
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
```

## Custom SSHD Port

### Method: /private/etc/services File

The **/private/etc/services** file on macOS contains the default port mappings for many services, including ssh. SSH ports can be changed by duplicating and commenting out the original Port 22 lines, replacing port 22 with your choice.&#x20;

The default entries are:&#x20;

{% code title="/etc/services (line 83 & 84)" %}

```
ssh              22/udp     # SSH Remote Login Protocol
ssh              22/tcp     # SSH Remote Login Protocol
```

{% endcode %}

## Resources

{% embed url="<https://www.godo.dev/tutorials/macos-ssh-server-no-password/>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://strangebutohwell.gitbook.io/knowledge/applications/ssh/ssh-on-macos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
