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/xinetd.pid`

*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.2008-11-08)

434.   How can I get around registering your real email with a given service? (or what's a good way to get a feed for a throwaway email?)   [jake/2006-06-02]
288.   Where does the smell of rain originate from?   [rupe/2001-11-20]
271.   I am stupid and forgot my root password for my OpenBSD box. Now what?!?!   [ross/2001-09-05]
225.   What do I use to write cool Palm software?   [combee/2001-11-01] ( combee/2001-09-21 )
189.   How do you get rid of the ^M characters that are visible when a microsoft text file is edited in UNIX?   [macki/2001-03-06]
171.   How do I read a huge file line by line in Python, without loading the entire thing into memory first?   [rupe/2001-02-01] ( enki/2003-10-20 )
131.   What does Jesse do to anything after a fresh linux install?   [jesse/2000-10-08]
78.   Where can I find the latest copy of nmap?   [rupe/2000-04-22]
38.   What did <Andrigaar> and <|PenZerg|> say to the HUMANS in #yak ?   [strick/2000-02-01]
20.   What is a good tool to beautify HTML? Can it handle the mess generated by many web-page generation programs, especially the bloated files created by Word2000?   [jamison/2000-02-10]