Running OS X services on alternate ports
Nov 27, '00 01:14:00PM
Contributed by: robg
| This hint only works for pre-10.2 systems |
Some people (such as myself) have the need to run OS X services (such as Apache, ftp, ssh, telnet) on alternate ports. In my case, my router has a mini-http server, so I can't use port 80 for Apache, and my ISP blocks all ports below 1000 to prevent servers.
How do you work around this in OS X? For Apache, it's fairly simple. From a terminal session, edit (note: edits referred to in this article should be done as the root user; 'su' before editing!) the file /Library/Web Server/Configuration/apache.conf, and find the line that reads "Port 80." Replace 80 with the port you would like to use -- keep in mind that visitors to your site will have to enter:http://siteaddress:portnum/
(where portnum is the number you chose)in order to see your pages.
Telnet and FTP are more troublesome, due to the presence of Netinfo. A friend of mine gave me the scoop, and I know this works, but I have no idea how it does so (at least I'm honest!).
From a terminal session, type:
echo 'ftp2 5021/tcp' | niload -m services .
echo 'telnet2 5023/tcp' | niload -m services .
Replace the 5021 and 5023 in the example with the port numbers you'd like to use.
Next, edit /etc/inetd.conf, and add the following lines (it's easiest to just duplicate the current ftp/telnet entries):ftp2 stream tcp nowait root /usr/libexec/tcpd ftpd -l
telnet2 stream tcp nowait root /usr/libexec/tcpd telnetd
Note that those are supposed to be tabs between fields, so don't copy/paste the above code!
ssh looks like it might be simple. The file named sshd_config in /etc contains a line that reads "Port 22" near the top. I would imagine (but have not yet tested the theory) that simply changing this to your desired port number would work.
Once you've done this, you can logout and login to restart network services, and you should be running on the new ports.
Comments (3)
Mac OS X Hints
http://hints.macworld.com/article.php?story=2000112713143850