How to Run an Ubuntu Server VM with VirtualBox (and login via SSH)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I'm going to show you how to set up an Ubuntu Server virtual machine using virtualbox and at the end of this video I'm going to show you how to log into that virtual machine via ssh in headless mode so let's go ahead and get started we're going to need a couple things here if you go to virtualbox.org and click on this downloads link you'll come to this page where you can download the virtualbox installer it's available for Windows Mac Linux all that good stuff I'm on a Mac so I'm going to get my Mac installer here we're also going to need an Ubuntu ISO image so you can go to ubuntu.com download and we want the server version you can do this with the desktop version which has a user interface but because in the future we're going to develop a website on here we're going to pick the Ubuntu Server option and getting the latest stable version 22.04 is perfect so we'll go ahead and download that okay so while that's downloading let's go ahead and install virtualbox so I'll open up the installer here and as it says here we'll double click this icon to execute the installer so in here we will click on continue install I'll type my password hit enter and that's going to go ahead and do the install the installation was successful software was installed perfect so we'll close out of that and on a Mac yes you can move the installer to the trash and now if I go I can either go to Spotlight and search for virtualbox or open it directly from my apps folder so let's go ahead and do that okay and because I actually have used virtualbox in the past I do have these other VMS you won't see this if this is the first time you're using virtualbox but that's okay because we're going to add a new virtual machine to this list and the way we're going to do that is by clicking this new button here and we're going to call this Ubuntu 22.04 and we're going to pick that ISO image that just finished downloading so I'm going to navigate to that on my computer which is in my downloads directory so I'm going to select that click open and it automatically detects the type and the version of Ubuntu that we selected now in this case I'm going to skip unattended installation I tried that a couple times and I didn't have much luck with it so all that means is we'll just have to manually select some options throughout the installation that's okay because I'll guide you through that so I will click on next and at this point you can configure how much of your system resources you're going to allocate to your virtual machine so in this case we're looking at two gigabytes of RAM which is good and one CPU core I'll bump that up to two CPU cores and I'll hit next a virtual hard disk of 25 gigabytes sounds okay for me so I'll click on next and this is kind of just a review of what we were installing so that looks good to me let's click finish okay now we have our virtual machine here in our list of VMS let's go ahead and start that up and what that's going to do is open up a window it does start pretty small but we can make that bigger by clicking down here going to Virtual screen one and we'll make it let's start with 200 see if that looks better that's okay for for this tutorial um so let's go ahead and install the Ubuntu servers so you can use your keyboard now to select your different options up and down and I'm going to hit enter for try or install Ubuntu server okay so let's go through some of these options here we're going to pick English as our language we can update the installer as we do the install so we will update to the new installer and that'll just take a few moments for that to happen as for the keyboard layout I'm going to select English us and you can pick between Ubuntu server and the minimal version I'm just going to pick the standard Ubuntu Server version and hit done if you need to do any special network setup you can do that on this page I'm going to accept the defaults which are probably good for you too hit enter I don't have a proxy so I'll skip this and the default Ubuntu mirror address is fine for us so we'll click enter again and the virtual disk that we created that was 25 gigabytes we want to use that whole thing for Ubuntu so we'll keep that option selected come down here to done hit enter and that looks good for our storage configuration so we'll hit enter again and because this is a fresh 25 gigabyte virtual disk drive we don't have to worry about losing any data so we can go ahead and continue here go ahead and type in your name pick a name for your server pick a username and choose a password and then hit done you have the option to enable Ubuntu Pro I'm going to skip that for now and hit continue and I do want to install the open SSH server which we're going to show you how to use at the end of this video and we'll go ahead and hit done if you want to install some additional packages go ahead and do that on this page I'm going to skip over this one and now the installation will occur so we can sit back and watch that happen and actually while that is happening you might notice that your mouse has gotten trapped within the virtual machine window the way to get that out is I'll put an error on the screen here it's this left command key so all you have to do is hit the command key on the left of your keyboard since there's two of them one on the right one on the left hit the left one and that'll release your mouse from the window as you can see here and now I can let that install in the background do other things on my computer and then come back in here so anytime your mouse gets trapped you can just hit that Escape key right there okay and a few minutes later our installation is complete as you can see right below my mouse here so what we're going to do now is reboot the virtual machine and if you do see those unmounting failures that is okay don't worry about that just let it do this thing for a few more seconds and at some point it will reboot and start back up and then finally you'll come to the login screen like this one which just got covered up by some additional output it's kind of confusing but if you just hit enter a couple times you'll see the login prompt show up so what it's asking here for is your username which mine was Tony then you can type in your password and that should log you into your Ubuntu desktop or I'm sorry your Ubuntu server on your local desktop in a virtual machine so what we're going to do now is try to log into it via SSH on a terminal know if I'm on Mac I'm on a Mac if you're on Windows then we're going to use the command prompts I have other videos about how to SSH on Windows but out of the box it's not going to work I'm going to open up a new terminal window and try to log in Via SSH so SSH Tony at localhost or you can use 127.0.0.1 but either way initially it's not gonna work because that Port is not open how do we open port 22 which is the SSH Port well we can come into our virtual machine inside of virtualbox go to settings and go to network Advanced port forwarding we're going to do is add a new port forwarding rule for from Port 22 for TCP protocol to Port 22 on the guest Port so from host Port 222 to guest Port sorry from host Port 22 to guest Port 22 which just means the guest machine the virtual machine it's going to be listening on Port 22 and we're going to use port 22 in our terminal window on our local machine so let's save that rule hit OK and I'm not sure I think it should just start working right away and it does this error message probably won't show up for you that's because I have connected to another server on my machine that says localhost so let me just fix that real quick okay and let's try that again so I'm going to do SSH my username at localhost and because this is now the first time I'm connecting to this machine do you trust it you can type in yes hit enter and now you can type in your same password as before and now you'll be logged into the Ubuntu virtual machine via SSH and my preference is to use this use a terminal window and start this up in headless mode because we don't really need to use the user interface in an Ubuntu Server virtual machine right so let me show you how to start this up in headless mode so I'm going to get out of here and we're just gonna we'll send the the shutdown signal now so the machine actually turns off and we got kicked out of our SSH session over here but the next time we can start this up in headless mode you just select your virtual machine over here and instead of clicking the big green arrow you click this drop down box here and you can start the virtual machine in headless mode which just means it's not going to bring up that user interface you can kind of see what it's doing in the background here in in the preview window but once that does come up we can just minimize our virtualbox manager window here open up a terminal window like we did before and then ssh in via that way and just like that so if you want to take this a step further and actually do something with your Ubuntu virtual machines such as running a website locally on your computer then check out this video next where I show you how to set up an nginx server a lamp server Linux nginx my MySQL and PHP and we'll run WordPress website on top of that I'll see you over there [Music]
Info
Channel: Tony Teaches Tech
Views: 18,817
Rating: undefined out of 5
Keywords: how to install ubuntu on virtualbox, how to install virtualbox, install ubuntu in virtualbox, install ubuntu on virtualbox, install ubuntu virtualbox, install virtualbox ubuntu, ssh ubuntu vm, ssh virtualbox vm, ubuntu virtual machine, ubuntu virtualbox, ubuntu vm, virtualbox headless mode, virtualbox install ubuntu, virtualbox ubuntu, virtualbox ubuntu tutorial
Id: wqm_DXh0PlQ
Channel Id: undefined
Length: 9min 54sec (594 seconds)
Published: Thu Jun 08 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.