Start a conversation

Changing SSH Port in Mac OS X

Overview

This article explains the process to change the SSH (Secure Shell) Port in Mac OS X.

 

Process

By default, Mac OS X uses port 22 for SSH. Follow these steps to change it:

  1. Open Terminal on the Mac.
  2. Run the following command:
    read -p "Please enter new SSH Port number: " sshport; sudo sed -i "-bak"
        -n "/SockServiceName/{p;n;s/>.*</>$sshport</;};p" /System/Library/LaunchDaemons/ssh.plist;
        echo "SSH Port $sshport. Restart service for changes to take effect."
  3. Enter the new port number.
  4. Enter your password.
  5. Restart the SSH service by either restarting the computer or running the following commands in Terminal:
    • ps aux | grep sshd - find the PID for SSH
    • kill -1 <PID>

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Priyanka Bhotika

  2. Posted

Comments