Remote SSH access via internet

I'd like to make SSH access to a Mac in China. The Mac is currently on a PC network with ports 407 and 5900 directed to it's local IP address. I have engaged remote login in Sharing panel.

Any advice would be appreciated.

G5/dual 2ghz/2.5gb RAM, Mac OS X (10.4.11)

Posted on Jan 20, 2008 3:19 AM

Reply
21 replies

Jan 20, 2008 11:27 AM in response to David McMillan

So this is your Mac in China that you are wanting to ssh when you are not in China? If you enabled remote login on that Mac in China then it is listening on port 22, and if port 22 traffic is forwarded through that Mac's local router, then you can ssh into it.

There are a number of posts in either this forum and/or in the networking&web forum about how to run ssh over a non-standard port (≠22) if you want/have to. I don't think that things will work out very well for you, though, if you have multiple services trying to listen on the same port, though.

The number of other posts also discuss tunneling things like unencrypted VNC and unencrypted AFP/AFS connections through ssh (giving the added benefit of being able to close the vnc and afp ports in the local router). Of course, the tunneled traffic is delivered to the correct and appropriate port when it comes out of the tunnel, so the services at the far end are not listening to port 22, they are listening to the port that they normally listen. I don't know if you could have a Timbuktu client connect to localhost on a port other than 407 or not, but if you could, you should be able to tunnel that connection through ssh to the Timbuktu session on the other end of the ssh tunnel as well. Many client applications do allow you to do that, so they are all securely tunneled through ssh, so you only need that one single port open in your router for ssh.

Personally, I really like tunneling everything through ssh because I gain comfort knowing that most eavesdroppers can't glean any intelligence from any intercepted traffic, and because I like public key authentication, which you can do with ssh, way better than username/password authentication; the former I believe to be way superior in preventing break-ins.

Jan 23, 2008 5:58 AM in response to David McMillan

ssh is a secure method. do you mean you want to change the port sshd listens on, or otherwise improve the security of ssh?

to start, use keys, not passwords. edit your /etc/sshd with the following lines:

ChallengeResponseAuthentication no
PasswordAuthentication no
AllowUsers (your short user name)

generate a public/private key pair and copy the key to your remote mac. you might want to do this before disabling ssh password logins.

then if you really want to change the listening port, you can do that by changing that in the sshd_config file and in the ssh.plist launchd item in /System/Library/LaunchDaemons/.

you can also use the /etc/hosts.deny and /etc/hosts.allow files to define access to specific IPs, hostnames, or ranges of machines.

clarify what you want to do, and we can help.

Jan 24, 2008 8:05 AM in response to David McMillan

I'd be worrying a helluvalot more about leaving ports 407 and 5900 open than I would 22! I'd be tunneling that traffic through 22 if I were you.

All of the ssh lockdown suggestions put forth here are good; personally I prefer public key authentication using dsa keys only with username/password authentication disabled (common username with weak password doesn't protect you much - but a PGP-like key exchange does) (in terminal, see "man ssh-keygen") coz' I can't always guarantee what domain or IP I may be affiliated - all this is discussed in numerous posts in this forum and I believe over in the Networking&Web forum, too, as well as the numerous online tutorial sites (Bill Scott and Tim Haigh, regulars here, have put together some pretty decent OSX-flavored tutorials on this stuff).

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Remote SSH access via internet

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.