How to SSH Into Your Virtual Machine
Alright, time to get back into it. Let's get some coffee and dive in.
I got this really nice bag of coffee beans from one of those dingy coffee shops near me. It has caramel flavoring in the grounds themselves. It's so good; you guys should definitely try something like that. It tastes like caramel when it's black, so you don't need any of that sugar-filled creamer.
To go with the coffee, I have some music from Apeiron queued up.
I am assuming that you guys already have a hot cup of coffee next to you. Take a sip and let's get to it.
Today, I will talk about how to Secure Shell (ssh) into the VM you created.
If you have experimented with the machine, you know that you can use it like a normal computer. It has a nice interface (GUI) like windows, but to access the true power of Ubuntu, you need to dive into its shell.
In the spy movies, you always see some people go to a coffee shop, open up their computer, and type really fast on something that looks like this:
What they are doing is working on a terminal. Don't let this analogy run too deep, though; most of the stuff the spies type are pretty inaccurate.
In this one movie, the spy was trying to get through a firewall, so it showed him typing something like "hack the firewall" into a terminal. I am happy to say that working with the shell is a little more interesting than that.
Think of the shell as a program to run programs. This allows users to execute a bunch of commands with input data. The shell is a command interpreter: it takes the commands you type and completes complex tasks to run them.
There are commands for creating directories, moving files, running programs, and so much more. But the true power of the shell is that it is a programming language with all the tools bundled in to make it do whatever you need. It can be used to automate tasks that are really boring, create your own commands, and complete complex tasks.
I'll show you how to "hack" like the spies do in the movies in a different post (cheesy one-liners sold separately).
If you downloaded Ubuntu, you will be working on the bash shell. There are many different kinds of shells that you can use. I'll list a few and describe them briefly, but you'll be fine sticking with the bash shell.
It's totally fine if you don't understand all this; we will talk about everything as we go along.
If you ssh into your VM, you can work directly on the terminal and have access to the shell. Or you can use the Graphical User Interface (GUI) (the point and click, like windows), but you won't have access to the true power.
You can use the terminal inside the GUI, but if you wanted to use your host machine, you would have to exit your VM. It's a hassle to do all that. Instead, you can access the shell of your VM while using your host machine.
There are a lot of different ways to do this. On some computers, you don't even need to install the software I use. But the program that I use is really powerful. There a lot of tools that come with it, but my favorite feature is how painless it makes transferring files between your host and guest machine.
Ok, enough talk.
I got this really nice bag of coffee beans from one of those dingy coffee shops near me. It has caramel flavoring in the grounds themselves. It's so good; you guys should definitely try something like that. It tastes like caramel when it's black, so you don't need any of that sugar-filled creamer.
To go with the coffee, I have some music from Apeiron queued up.
I am assuming that you guys already have a hot cup of coffee next to you. Take a sip and let's get to it.
Today, I will talk about how to Secure Shell (ssh) into the VM you created.
If you have experimented with the machine, you know that you can use it like a normal computer. It has a nice interface (GUI) like windows, but to access the true power of Ubuntu, you need to dive into its shell.
In the spy movies, you always see some people go to a coffee shop, open up their computer, and type really fast on something that looks like this:
What they are doing is working on a terminal. Don't let this analogy run too deep, though; most of the stuff the spies type are pretty inaccurate.
In this one movie, the spy was trying to get through a firewall, so it showed him typing something like "hack the firewall" into a terminal. I am happy to say that working with the shell is a little more interesting than that.
Think of the shell as a program to run programs. This allows users to execute a bunch of commands with input data. The shell is a command interpreter: it takes the commands you type and completes complex tasks to run them.
There are commands for creating directories, moving files, running programs, and so much more. But the true power of the shell is that it is a programming language with all the tools bundled in to make it do whatever you need. It can be used to automate tasks that are really boring, create your own commands, and complete complex tasks.
I'll show you how to "hack" like the spies do in the movies in a different post (cheesy one-liners sold separately).
If you downloaded Ubuntu, you will be working on the bash shell. There are many different kinds of shells that you can use. I'll list a few and describe them briefly, but you'll be fine sticking with the bash shell.
- Bash Shell
- Stands for Bourne Again Shell(Pun on an older version)
- Aliases
- Command line editing
- Written by Brian Fox
- Csh Shell
- Like the C programming languages in terms of syntax
- Created by Bill Joy in the late 1970's
There are a lot of shells, but all shells can do the following:
- Filename Wildcarding
- Piping
- Here documents
- Command Substitution
- Variables
- Control Structures
- Condition-testing
- Iteration
If you ssh into your VM, you can work directly on the terminal and have access to the shell. Or you can use the Graphical User Interface (GUI) (the point and click, like windows), but you won't have access to the true power.
You can use the terminal inside the GUI, but if you wanted to use your host machine, you would have to exit your VM. It's a hassle to do all that. Instead, you can access the shell of your VM while using your host machine.
There are a lot of different ways to do this. On some computers, you don't even need to install the software I use. But the program that I use is really powerful. There a lot of tools that come with it, but my favorite feature is how painless it makes transferring files between your host and guest machine.
Ok, enough talk.
Step 1: Download mobaXterm
This is my favorite way to ssh into anything.
Once you go to their website, click "GET MOABXTERM NOW."
Then choose "Home Edition".
And finally, download it.
It will download as a zip file, so unzip it after the download.
All you need to do to unzip is to go to where you downloaded the file, right-click, and choose extract. You can extract to where ever you want to.
Ok, know you have the tools to ssh. All you need to do now is configure.
Step 2: Configure the VM
Make sure that your VM is shut down for this.
Open VirtualBox and choose "settings" for your machine.
Go to the "Networks" tab.
This page is where you can mess with your computer's networking. There are 4 adapters you can mess with.
There are a few options for these adapters, but here is a nice table from VirtualBox that will explain things.
To ssh into your VM, your host would have to talk to the VM. So we will set one of the adapters to "Host-only." You can use "Bridged," but there are a lot of nuances to it.
To set one of the adapters to "Host-only," click on "adapter 2."
Then enable the network by clicking on the box and choose "Host-only" from the drop-down.
Hit "ok," and start the VM.
Once you are in, you can make sure that the internet is working by opening terminal and typing "ping google.com"
If you get a response like this:
(My VM is not in full screen)
It's working.
Hit 'Ctrl' + 'c' to stop the command. This completely aborts any command.
Now that the networking is all set up, you need to make sure that your SSH is enabled.
Type "sudo apt-get install ssh" into your terminal.
Hit enter and put in your password if asked.
Type 'Y' when it asks you to continue.
You are done enabling your VM.
Step 3: Connecting to Your VM
To connect, you need two things: MobaXterm and your VM's IP Address.
You already have MobaXterm, so all you need now is the IP Address. To find your IP Address type "ifconfig" into your terminal.
If your system doesn't have that command, download it with "sudo apt install net-tools"
Now, if you typed "ifconfig," you should get something like this:
If you set your network settings exactly like mine, your IP Address is:
If you did it differently (setting host-only to a different adapter), you should find your IP Address respective to the adapter number you choose. If you set "Host-only" to adapter 3, your IP address would be on the 3rd block of text.
Now that you have your IP Address, it's time to open MobaXterm.
Go to the place you unzipped Moba and run it (on your host machine).
I already have a few sessions set on my Moba so you can ignore all that extra stuff in my screenshots.
After your Moba opens, click the "sessions" tab at the top and choose "New Session."
Once that opens, choose the ssh option.
Type the IP Address of your VM into the "remote host" section, and put your username into the "username" section.
And finally, hit "Ok."
Enter the password as prompted.
Now you can say what they say in the spy movies: "I'm in."
That's it; you're done. Now you're connected to your VM through an ssh and have access to its shell.
You no longer need to use the VM GUI to do tasks, which is really great. Especially if your computer is slow. It's easier on your machine to ssh rather than to use the GUI.
I want to keep talking about the kinds of things you can do with the shell, but, sadly, I have too much school work.
Until next time! Keep that coffee flowing.






















Comments
Post a Comment