Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Running OS X services on alternate ports System

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:
(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.
  • Currently 1.90 / 5
  You rated: 3 / 5 (10 votes cast)

Running OS X services on alternate ports | 3 comments | Create New Account
Click here to return to the 'Running OS X services on alternate ports' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
SSH Walkthrough?
Authored by: Anonymous on Dec 23, '00 04:58:00PM

Does anyone happen to have the URL for any sort of walkthrough to get SSH running under
OS X/Darwin? I've been fighting like mad for the last couple days to get it running and it won't
recognize the generated keys, among other problems. Thanks!

[ Reply to This | # ]
SSH Walkthrough?
Authored by: robg on Jan 05, '01 01:56:26AM
Sorry it took so long, but I finally got around to a write-up on enabling SSH. It's on the homepage now, so hopefully you've seen it, but you can also read it by clicking this link.

[ Reply to This | # ]
Alternate SSH port
Authored by: robg on Feb 01, '01 11:15:33AM

I set up SSH on my new partition last night, and verified that the instructions above for changing the port number do, indeed, work as expected - just change "Port 22" to whatever number you'd like to use.

Of course, I then forgot to tell the firewall to let that port through, so I can't get in today...oh well!

[ Reply to This | # ]