This is an article about SSH and your Mac. I've mentioned SSH before but now I thought we'd take a closer look at how you can use SSH with your home Mac to do various things and do it encrypted, meaning it's much more secure. In this series we will primarily use the Terminal but don't be scared, it's really not that hard. In the third part we will get to using a GUI interface to remotely control your home Mac.
Enable SSH on your Mac is really easy. Go to System Preferences > Sharing > Services, and click on Remote Login. That's it. To begin with,we will assume you are using SSH inside your network, meaning not behind a router. Later, we'll deal with connecting to your home Mac while you are away from your home. To login to the other machine using the Terminal, type ssh, your username, and the IP-address of the remote Mac, for example:
ssh emiratesmac@192.168.1.100
If you're connecting for the first time, Terminal will tell you that it doesn't know about the remote machine and asks you if you want to continue:
The authenticity of host '192.168.1.100 (192.168.1.100)' can't be established.
RSA key fingerprint is 3f:d3:54:bf:a3:df:1c:3b:e6:cd:a7:8b:34:05:75:0c.
Are you sure you want to continue connecting (yes/no)?
You type in "yes" and you should get a message saying the remote machine has been added to a list of known hosts:
Warning: Permanently added '192.168.1.100' (RSA) to the list of known hosts.
Finally, you're asked for your password, so you type your password and press enter. When you've entered your password, Terminal will print a welcome message:
Last login: Sun Jul 30 20:00:54 2006
Welcome to Darwin!
So what can you do via a SSH connection? You can basically do anything you can do with a Terminal sitting at your Mac. Here are a few examples:
See what applications and process that are running:
top
An alternative is the ps command:
ps -aux
If you only want to see applications running, not all processes, you add a bit to the ps command:
ps -aux | grep '.app'
If you want to see what's actually on the screen on the remote computer, you can use the screencapture command:
screencapture -x screen.png
Quit an application or process (you find out the processid by running ps as shown above):
kill processid
You can edit text files on your home-Mac. There are many text editors you can choose from. I tend to use pico the most because it's pretty user-friendly. To edit the file "mytextfile.txt" you would type:
pico mytextfile.txt
Copy a file:
cp filename
Get help with any command:
man nameofcomman
There are also a lot of other things you can do once you have a working SSH connection, like copy files between computers using SFTP (secure alternative to FTP), and do backups with RSYNC (some good instructions here). Next we'll take a look at connecting to your home-Mac while away from home. We'll look at what you need to change in your router, and what you can do on your home Mac to make sure it's all as secure as possible.