screen3

Remotely Control a Computer: A Basic SSH Tutorial

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:

ssh user@hostname

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:

say "Hello"

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.

63 Comments

  1. fred

    03.08.2011

    Reply

    Please reply! I went into terminal, and typed in the following, ssh user/###
    the ONLY thing I replaced was the “###”, and i put in the ip of the target in its place. I hit enter, and terminal said “connection refused”.
    what do i do?????

    • Jeff Browning

      03.09.2011

      Fred, the command is ssh user@IP, not a backslash (/). A slash would be used in filepaths, such as cd user/desktop/file.fileextension, as opposed to remotely connecting to another machine.

      Hope this helps! If it doesn’t, and you ARE using @ instead of / and it’s a typo, then my question to you is this: are you trying to ssh into a computer outside of your local network? A process like that required port-forwarding, which is something we plan to cover in an upcoming article.

  2. Charlie

    05.24.2011

    Reply

    Is there a way to find the IP of the target computer? I have an admin account on it, I just don’t have physical access to it. It is on my LAN though.

  3. Charlie

    05.24.2011

    Reply

    If possible, I would like to know how to get that IP (if it’s still relevant) when it’s not on the LAN.

    • Jeff Browning

      05.24.2011

      You can use a service such as http://www.whatismyip.com/ to find the IP address of the computer while you’re logged in, which, since you have an administrator account, should be easy enough. The thing is, that’s the external IP address and you generally only have a single external IP address PER LAN/Router. If you want to be able to ssh using that external IP address, you would have to use port forwarding (we’ve got an article on it here, http://www.hackmac.org/hacks/workarounds/port-forwarding-basics/).

      You can also just use the computer’s shortname or getting it’s local IP address from the computer itself (it’s IP address on the LAN, not on the internet. You can find that in System Preferences under “Network”)

  4. Kabir

    06.05.2011

    Reply

    the SSH basic tutorial is for Windows OS or Linux????????????

  5. Kabir

    06.08.2011

    Reply

    thanks for reply.

  6. Kabir

    06.08.2011

    Reply

    will u provide me any link to free download MAC OS .
    thanks

    • Jeff Browning

      06.08.2011

      Sorry, we don’t deal with illegally acquired software.

    • Jeff Isaacs

      12.01.2011

      try thepiratebay.org
      but it doesn’t matter because Ubuntu 11.10 is out. This is what you should be getting..

  7. Saqui

    07.10.2011

    Reply

    is this hack onl for hacking other mac computers or is it possible to hack other softwares such as windows or linux

    • Jeff Browning

      07.10.2011

      I’m sure there are similar commands via the command line in Linux and Windows.

      Most of the commands in Mac OS X should be identical to those in Linux.

  8. BG13

    07.12.2011

    Reply

    how do you log out again? do you just close terminal or does that leave it still connected?

    • Jeff Browning

      07.21.2011

      Simple: type “logout” without quotes.

      Closing Terminal will also sever the connection, but just to be sure, always logout before closing.

  9. John

    08.13.2011

    Reply

    okay so i did it all and it worked and i was just playing around making it say words and stuff and i didn’t realize the other computer was going dead and then it died. so i think it kicked me out or lost the connection and now i can’t get back in. i typed in the command and this is what happened:

    ssh user@####
    ssh: connect to host #### port 22: Connection refused
    so i tried again ssh user@####
    ssh: connect to host #### port 22: Operation timed out

    Do i need to just restart the computers or what? was i automatically logged out?

    • John

      08.13.2011

      nevermind. I had to turn on remote login. that’s what it was. Is there anyway to bypass the remote login feature? perhaps if i were in a situation where that computer is inaccessible?

    • Jeff Browning

      08.14.2011

      Not that we know of, but it’s something that we’re looking into.

      We’ll let you know if we get anywhere.

  10. Richard

    08.28.2011

    Reply

    It is possible, if you get into some serious cracking. For example, you could use a trojan. But it would be very hard.

  11. Elliot

    09.05.2011

    Reply

    Is there a way to do this without having to be on the target computer at all? Like hacking on to it. Any websites that explain this?

  12. zahirzikri

    09.07.2011

    Reply

    pliss give me your ebook…

    • zahirzikri

      09.07.2011

      never mind…

  13. zahirzikri

    09.11.2011

    Reply

    hello, i tried many times but keep failed
    command always say “Permission denied (publickey,keyboard-interactive).” even thought i enter the right password. how to overcome it?

  14. Troy

    09.27.2011

    Reply

    once i enter the ssh user@ip the terminal goes blank and nothing shows up not ever a message..

    thanks

    • Jeff Browning

      10.23.2011

      Did you replace “user” with the username and “ip” with the I.P. address of the computer?

  15. Adam

    10.01.2011

    Reply

    is there a way to anonymously and remotely hack into a macbook pro that’s 3 – 4 years old? what information would you need to be able to do that? i know the main login password for the computer, but don’t know where to begin to access / open it remotely and what to do once i have.

    • Jeff Browning

      10.23.2011

      You would have to enable remote login and, depending on where you’re trying to control it from, forward some ports in the router. We’ve got a couple of guides on that.

  16. kevin

    10.11.2011

    Reply

    Mac os default setting is set to; remote login off. Is there an alternate way to switch the setting without having physical access to the computer?

    • Jeff Browning

      10.23.2011

      If you can somehow log into the computer, you can enable SSH with this:
      sudo /sbin/service ssh start

      But usually, you need SSH to log into the computer remotely, so it’s a bit tricky.

  17. george

    11.10.2011

    Reply

    how can i open a web browser in the computer that i am remotely logged into?

  18. Martha

    11.11.2011

    Reply

    Some of the computers I’m planning to target need an admin username and password to turn on remote login. I don’t really want to setup a whole other admin on the computers I’m targeting. Is there any possible I can get around the admin username and password? Or is it possible to setup one admin that can be used on any of the computers in my home. Thanks!

  19. buddy

    11.21.2011

    Reply

    i successfully connected and it asked for a password and i typed in the right password (i know this for a fact because its my own password) and it rejects it. is there some other password than the regular login window password that i am missing?

  20. Jeff Isaacs

    12.01.2011

    Reply

    Is it possible to connect to another Mac computer with access to files from over the Internet? If all you had was the IP address, what would be the next step in gaining access to the computer?

  21. Ryan

    12.07.2011

    Reply

    So I am having a huge problem with my SSH.. I have looked everywhere, top and bottom only for someone to help me with it.. I finally decided to come to you guys because it seems like it is actually answered. So.. Have me an Iphone.. Trying to get into my computer’s SSH.. However.. when it asks for the username.. I have NO idea what to put.. I thought it was the login for my computer but thats not it.. (mind you I do have a PC sorry I know its not mac but figured I had an iphone so I could get help still) so example.

    “username@computerip”
    this is great info, but what is my username? and then when it asks for a password.. what is my password? I have been up ALL night trying to figure it out. Please if I could get any answer at all I would love it! thank you.

  22. Chris

    12.16.2011

    Reply

    How would you find peoples ssh addresses to connect to?

  23. Stan

    12.16.2011

    Reply

    How do you find the user? I have the ip address and host name , but not the user!

  24. Robert

    12.18.2011

    Reply

    I connected and everything is working great, but is there a way to change the voice used on the computer when speaking commands? im using ConnectBot on the android.

  25. Sgtpepper

    01.31.2012

    Reply

    Is this only possible while doing this on the same network of the target computer? Or can I do it from another computer someplace else and if so how?

  26. cJames

    02.11.2012

    Reply

    Yeah Hi…

    I’m a little stuck on this one. Because, say I was to gain control of a macbook, in your free ebook (“hack-a-mac” you explain that to get the password, you have to be using the computer you are going to hack…
    in which, you can only do all this in the root user. and to set up a root user, you are going to need the user’s password…which you need…in which you don’t to decrypt it, since you already know it….

    Umm…help??

    Thanks though,
    love this stuff.

  27. jessica

    02.14.2012

    Reply

    I did everything, but it kept prompting me for password even though i’m positive it’s correct password

  28. assassin

    03.20.2012

    Reply

    well i did try it and the target computer was nowhere near me, but mine and the target computer were connected via the internet, it showed a message saying: network is unreachable, is it a problem because i connected it via the internet or do i have to create an ad-hoc and only then will it work?

  29. Bwanswa Deogratious

    03.27.2012

    Reply

    Can someone hack an ATM.

  30. taylor

    04.04.2012

    Reply

    i typed hisusername@hisip
    and typed enter it says connection refused.
    Does his mac’s remote log-in should be on?

  31. bob

    04.10.2012

    Reply

    obtain the password part of you hacking guide doesn’t work

    • bob

      04.10.2012

      i meant obtain the hash

  32. Anya

    04.16.2012

    Reply

    My friend’s husband tried to do this terminal thing on my MacBook air, was that mean he tried to hack my computer or remotely set it up? He said he just want to connect or open his Mac but he did what steps you’ll saying here. And he knows my password to log in into the computer. That’s why I searched this website for him to stop whatever fishy plan he’s into it!

    And if incase yes, how will I stop it? (he’s kinda creepy, please help! )

  33. Mahli

    04.18.2012

    Reply

    I was trying to get into my friend’s mac using the ssh and got to the point of the password i tried three times at it, then it showed up like this i have the password and was typing it in correctly.
    Warning: Permanently added ‘#######’ (RSA) to the list of known hosts.
    Password:
    Password:
    Password:
    Connection closed by ########

    How do i fix this problem

  34. nick

    05.10.2012

    Reply

    this is what i get:

    ssh: connect to host 82.170.221.163 port 22: Operation timed out

    [Process completed]

    If i do it on this computer, with the IP provided and the username then i get the authenticity yes/no pop up.

  35. niko

    05.15.2012

    Reply

    i put the “ssh@…” when i press enter, nothing happens, the mouse goes to the next line, no warning or anything

  36. Somebody

    05.22.2012

    Reply

    Hi, great guide, but is there any way of getting the password remotely from a user on any computer? Through SSH maybe?

  37. David

    05.28.2012

    Reply

    If I know the root password of the target computer but dont have an actual admin account on it can I still remotely access it?

  38. jt

    05.31.2012

    Reply

    Hey my friend had his macbook stolen. we share a dropbox account is there anyway to get into it thru dropbox so we can turn on the camera to see who has it? he believes it’s some people he knows but has no proof.

  39. isai

    06.11.2012

    Reply

    can you remotely control a pc with a mac ?

  40. Gus

    06.11.2012

    Reply

    I tried the above instructions and got this response:
    “ssh: Could not resolve hostname hostname: nodename nor servname provided, or not known…(IP addy then ###$).”
    What does this mean?

  41. loek

    06.12.2012

    Reply

    i have typed into my terminal ssh user@hostname enter ssh user@#.#.#.# enter
    but then say terminal ssh: connect to host ********* port 22: Operation timed out
    why is dosnt work

  42. Kier

    07.15.2012

    Reply

    Do you have to be on the same Wifi as the computer you are hacking or can you do it from a different wifi source?

  43. Lane

    07.22.2012

    Reply

    How would one go about seeing the screen of another computer after remotely logging in to it?

  44. Shaun

    07.23.2012

    Reply

    When I try this I get to the password stage and correctly enter the password (even tried on my own computer), however I get the message-Permission denied (publickey,keyboard-interactive).

    Please help

  45. Charlie

    09.13.2012

    Reply

    Hey, so if I have enabled the root account and turned on remote login through root. When I SSH to the target computer, will users of other accounts on that computer see what osascript i send to it? For example, if my friend is logged onto his account and I want to run osascripts to his account but I am SSH’ed to root?

  46. Josh

    10.04.2012

    Reply

    Hey, I am using a Mac and the computer I plan on hacking is a PC, will my Mac be able to control the PC? Or?

  47. Johanne

    10.14.2012

    Reply

    It only comes up alooot of y’s ? When I type in yes… What have i done wrong?

  48. James

    11.14.2012

    Reply

    Is it possible to log in with the root password and obtain the hostname for that account? Essentially could one could enter ‘”root@’obtained hostname’” and use the root password when prompted?

Leave a Reply