An addendum to my post above... to tighten security and configure the SSH server as per some of my recommendations above, edit
/etc/sshd_config as follows:
To disable the inherently insecure classic account password challenge authentication method, change the line:
Code:
#PasswordAuthentication yes
to:
Code:
PasswordAuthentication no
Note the removal of the
# (as well as the change from
yes to
no).
This should be done because if you don't,
it provides access to anyone lacking the private key but who may have obtained (or who might be able to guess) an account name and password (this info is much easier to obtain than you might think). It is the weakest point in your security. Key pairs are so much stronger and very easy to use. Close this door to your system!
It's also a good idea to explicitly state which accounts may be accessed remotely. This adds another level of security. To do this, add an
AllowUsers directive naming the accounts (multiple
AllowUsers lines are allowed, as are multiple names in the directive). For example, adding:
Code:
AllowUsers leslie@203.120.14.5 terry
limits ssh access on your computer to only the accounts
leslie and
terry. Furthermore, the account
leslie may only be accessed from IP address 203.120.14.5. The account
terry has no IP address restrictions, however, and anyone anywhere on the internet may connect (provided they provide the proper session authentication). Partial IP addresses and wildcards are also supported (see appropriate documentation for specifics).
If at all possible, you should limit the IP, as in the
leslie account example, as this adds yet another level of security. If, for example, the private key to the
leslie account falls into the wrong hands (and isn't password protected), it can only be used from the specified IP address. This isn't a foolproof failsafe, but it's far better than none at all.
The current default for
RSAAuthentication and/or
PubkeyAuthentication is yes, which means public keys are enabled (but not required) by default, so you shouldn't have to specify those options. This is just as well as these keywords seem to be in flux and the standards could change later. [Note: Since classic account password challenge authentication is also enabled by default, either method may be used for session authentication (by default). That is why i recommended you turn it off above, thus leaving public key authentication as the only remaining authentication option.]
So if you apply all the recommendations above, the only people who can log into your Mac are those with the proper private keys. Having account names and passwords will
not grant them login capabilities through ssh. In fact, those with the proper keys don't even need to know their account passwords (and this may be a wise security precaution, depending upon your circumstances). For additional security, you can add a password to protect the private key (which is
not related to the account password).
Enjoy!