My home computer: Windows 7 laptop also running an Ubuntu virtual machine via VirtualBox with a bridged network connection (as opposed to NAT).

My work computer: A Windows 7 computer.

I want to SSH into my home machine remotely from my work computer because I want to be able to run / manipulate my LAMP webserver (which involves MySQL stuff, yes). I am running Apache on the VirtualBox and it would be great to have control from afar.

To my understanding, SSH is a way to "log in" to your terminal remotely, yes? I've Googled this subject (which led me to things like PuTTY) but am having difficulty understanding how all of this works or what I need to set up or keep in mind as a beginner.

However it would also be nice to have the ability to SSH in from anywhere, if possible! that'd be really convenient.

  • We might be able to help but you haven't explain what you actually need. ssh is a protocol that allows you to connect to (usually) remote computers. That said, please don't combine multiple questions in a single post, break them into separate ones instead.
    – terdon
    Jul 2, 2014 at 16:09
  • It's all technically one question, since I don't know if SSH allows me the sort of access that a "remote login" may not to SQL. If it does then I can go forth with asking how to SSH correctly. If not, then I may need something else. Otherwise it's possible that I ask how to SSH and then at the very end say "oh BTW my remote logins for SQL are disabled" "WELL WHY DIDN'T YOU SAY SO" etc. Hindsight is 20/20
    – user51819
    Jul 2, 2014 at 16:10
  • My guess is that the remote login feature in SQL is for access from outside of the system (as in from a remote web service or something). If you are using SSH, then it will be like you are a local user and you can use SQL, since it won't be able to tell that you're not physically there (well, technically, it might be able to, but it probably won't). Jul 2, 2014 at 16:12
  • Unfortunately, you will need to be way more precise in order for us to help you. What was the exact command? (no "or something like that" please) What exactly are these remote logins you're talking about? Where did you see a message concerning them? If you mean mySQL remote logins, they have nothing to do with ssh. Once you've logged in via ssh, you are basically on the remote machine, it won't be a "remote" login as far as mySQL is concerned. Please edit your question and clarify.
    – terdon
    Jul 2, 2014 at 16:13
  • @saiarcot895 That is what I suspect as well but just wanted to be sure
    – user51819
    Jul 2, 2014 at 16:13

2 Answers 2


To install/configure SSH you should check out one of many guides you can find browsing the internet, this one for example.

You can connect to your viritual machiene via SSH using the following command:

ssh user@ip

You will thereafter be prompted to enter your password. To be able to connect you need, as said, an IP. When connecting locally you have a local IP. You can check this address for the current system using the ifconfig command. Example:

eth0      Link encap:Ethernet  HWaddr e8:39:35:42:ed:96  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::ea39:35ff:fe42:ed96/64 Scope:Link
          RX packets:85385 errors:0 dropped:0 overruns:0 frame:0
          TX packets:77885 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:48235010 (48.2 MB)  TX bytes:9640323 (9.6 MB)

The inet addr being your local IP address, in my case If I would connect to my SSH server on my computer I would therefore execute the following:

ssh [email protected]

To allow connecting from outside of your network you are required to forward the incoming traffic, on the port SSH is running on, to your local IP address via a admin panel for your router. Some routers may not support this and the admin panel work differently between manufacturers. You can always call customer support if you are stuck with this issue.

To check your "global" IP address you can visit this website: what's my IP?

When connected to your "server" through SSH you can perform various tasks such as SQL:

mysql -u root -p -h

In the above scenario root is the user, password is enabled through -p and the host is (your local computer).

You can also access files using nano or any other text editor like the very popular and powerful (and complicated) vim. All in all you now have the power of a terminal in your hands, that is if you connect via PuTTY.

Connecting via, say Ubuntu's file manager, gives you a better visual experience and allow you to edit files in a GUI editor rather than through the command line. Similar programs exist on Windows, you'll have to figure that one out yourself.

  • So SSH is a "server" (sort of like Apache?) that I have to always have running on my VM? Also what exactly does "mysql -u root -p -h" do?
    – user51819
    Jul 2, 2014 at 17:12
  • And when you say "ssh [email protected]" do you literally type "user" or your username?
    – user51819
    Jul 2, 2014 at 17:13
  • A SSH Server is the listening part if so to speak. It waits for you to make a request to sign on. It needs to be running for you to be able to connect. You connect to ssh with the username on your virtual machine. As for the mysql command... it connects to mysql. root is the username for mysql, is the IP. Should be if it's a local connection though, which this is...
    – Xweque
    Jul 2, 2014 at 19:39
  • I still don't quite understand what -u and -p -h do but thank you for the answer!
    – user51819
    Jul 2, 2014 at 19:54
  • -u is followed by the username. -p indicate that you want to enter your password and -h is followed by the host.
    – Xweque
    Jul 2, 2014 at 20:29

If you want to ssh to your VM (or even your computer) from anywhere your host(work) computer must have an IP which you may rent from your ISP if they offer.

But if you want to ssh to your VM from your own computer it's due to your VirtualBox setup. Navigate to your VM settings, network tab. Attach your VM to NAT and in advanced, you should setup port forwarding as the following:

Protocol -> TCP, HostIP ->, Host Port -> 1222, GuestIP -> (your VM ip shown via command ifconfig), GuestPort -> 22

Finally you can ssh to your machine via ssh [email protected] -p 1222

  • Thanks! This is what I needed. 3 years after the question is asked.... Aug 3, 2018 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .