This article will be all about using SSH, or Secure SHell. It allows you to execute commands remotely so that another computer performs the actions. As I’m sure you’re thinking right now, SSH has many, many uses.
In this article, I’ll be telling you how to connect to another computer via SSH, and then how to execute some basic commands. If you want to use SSH, you need to make sure that remote login is enabled on the target computer.
If you don’t know how to do this, you should subscribe to our email list and we’ll send you a free ebook that includes that information! It’s called Hack a Mac With Only 30 Minutes of Physical Access. In addition to the information about enabling remote login, it details step by step instructions for getting into somebody’s computer and erasing all traces of you being there.
How to Login
Let’s start with the first thing you should know how to do: connect to the target computer. First you’ll need to open up Terminal (Applications > Utilities). Then type the following command:
So what does that mean? I’ll break it down for you.
ssh is the command – it means that we’re going to be using SSH. Pretty simple.
user is the shortname of the user of the target computer.
hostname is the IP address that you’ll be connecting to.
What’s a shortname? It’s the name you type into the login box when you want to login. I’ll also show you how to find it below.
Now that you know what each component means, I’ll tell you the easy way to get them. Go to your target computer and open up System Preferences. Go to the Sharing Tab and click on Remote Login on the left side. Then, in the middle of the screen you should see “To log in to this computer remotely, type “ssh user@#.#.#.#”.”
That’s what you have to type. The user is the shortname, and the numbers are the hostname. It’s that simple.
Now that you’ve entered that command into Terminal, hit enter. Assuming it works and you’ve never used SSH to access that computer before, Terminal will display: “The authenticity of host ‘#.#.#.# (#.#.#.#)’ can’t be established.” And then some more text. Type
yes and hit enter again. Terminal will display a warning, but that’s fine.
Next, Terminal will prompt you for a password. This must be the password of the user account you’re using SSH to access on the target computer. Don’t know it? You should check out our ebook that I talked about at the beginning of the article. It details exactly how to get that password.
Assuming you know the password, type it in (nothing will display when you’re typing, but that’s fine). Hit enter and you’re in! You’ve successfully remotely logged into another computer!
What You Can Do Now
Now that you’re remotely connected, you can do anything! Really, I mean it. You can do anything.
If you want to execute Bash commands, all you have to do is type them in and hit enter. For example:
That will make the target computer say “hello” out loud. If you want to learn more about using Bash, check out our excellent Bash 101 series.
Also, you can run Applescript on the target computer. For example:
osascript -e "Set volume 7"
That will set the volume at its highest setting on the target computer. We have an excellent article on Running AppleScript from the Command Line if you want to know more about that. If you’re curious about how to actually write AppleScript, you can look at our new series, AppleScript 101.
From here, the options are limitless. You can do anything now that you have remote access to their computer. Good luck and have fun!
The contents of this guide are for educational use only. For more information, see our Disclaimer.