by leif

How can I change which port sshd listens on in Mac OS X 10.3 Panther? (hint: not in sshd_config)

If you check the "Remote Login" box in the Sharing panel in System Preferences on a Mac OS X computer, you will enable the built in OpenSSH server. In previous versions of OS X, you could configure which port it listened on by editing the "Port" line in /etc/sshd_config. In Mac OS X 10.3, sshd is (strangely) run from xinetd, so the Port configuration line no longer has any effect.*

xinetd appears to rely on /etc/services to figure out port numbers, so the easiest way I found to change the ssh port is to change it there. You can view /etc/xinetd.d/ssh, and could possibly add a port line there, but the xinetd.conf man page says "If this attribute is specified for a service listed in /etc/services, it must be equal to the port number listed in that file.". So you may as well just change it in /etc/services I think.

To modify the file in place, you could use this command:

sudo perl -pi -e 's!^(ssh\s+) \d+/!$1 2200/!' /etc/services # changes it to port 2200
Then you need to HUP xinetd:
sudo kill -1 `cat /var/run/`

*Actually, if you want to start sshd manually, ie not via the Sharing GUI, it will ofcourse run as a daemon and use it's configuration file as expected. But if you do it the way described above, you can still turn ssh on and off with the OS X GUI, and have it started automatically, etc.


Read more of   The Yak's Frequently Questioned Answers   (mod.2010-02-10)

441.   What is Conware?   [jake/2006-12-22]
400.   How can I change which port sshd listens on in Mac OS X 10.3 Panther? (hint: not in sshd_config)   [leif/2004-01-24]
399.   What are some common methods of radio-based navigation?   [overcode/2004-01-03]
368.   Do Laws of Physics apply to Software such as PostgreSQL and MS Windows 95/NT?   [strick/2003-08-25]
293.   where can i find data about the most common names in the USA?   [jesse/2001-12-05]
210.   Where can i get a cool e-mail alias or   [josh/2001-04-04]
199.   Where can I find pictures of cool PC cases?   [rupe/2001-03-13]
198.   What tiny laptop does strick travel with?   [strick/2001-03-13]
124.   How do I make common modifications to my Gnu Emacs .emacs file?   [rupe/2000-09-26]
9.   Where is matt.html's home page?   [strick/2000-01-18]