Check out a free preview of the full Complete Intro to Linux and the Command-Line course
The "SSH & Secondary Machine" Lesson is part of the full, Complete Intro to Linux and the Command-Line course featured in this preview video. Here's what you'd learn in this lesson:
Brian explains that SSH allows the creation of an intranet, and demonstrates how to create a secondary virtual machine.
Transcript from the "SSH & Secondary Machine" Lesson
[00:00:00]
>> We are gonna get into talking about SSH. This ends up being a super important topic for many engineers for a variety of reasons. But SSH stands for Secure Shell, and allows you to connect from one computer to another computer. I imagine many of you have probably tried this before in some capacity.
[00:00:19]
And if you ever use Git, there's a decent chance you've used it in Git, because Git underneath the hood uses SSH. Now this particular section I'm gonna show you using multi-pass and using some specific features to multi-pass. So if you're using something like WSL or VirtualBox, I think this section you'll probably just have to watch, or you could set up another VM in the cloud and connect to that.
[00:00:40]
That's kind of up to you. But yeah, let's go ahead and get started. So again, SSH allows you to connect from one computer to another, and allows you to remotely execute commands on a different computer, right? So this will be like I have a computer running out in my server farm out in Azure or AWS, and I wanna connect to it, do something and then disconnect, right?
[00:01:06]
I mean when I used to run my own servers on DigitalOcean, I used to do this very, very frequently. What we're gonna do is, we're going to run a second VM locally on our computer, and then we're going to connect to that VM using a different VM. So we have two VMs, and we have one VM connect to the other VM.
[00:01:26]
I mean, this isn't gonna be super useful from the perspective of, you would never really need to connect to a second VM from the first VM, you could probably just use your host computer to connect to the second VM. But nonetheless, I wanna show you how to do this.
[00:01:39]
Okay, so what we're gonna do, is we're gonna get a second VM running. So if you're in macOS like me, you're gonna open your terminal here. I'm gonna open a second term terminal here. You can do this with a new tab here. Okay, but notice this one looks different from this one.
[00:02:02]
This is actually my Mac terminal. You can see here that this is not even running bash, this is running Zsh. And I'm gonna run one command here. If you're running Windows, you're gonna open PowerShell, and you can just hit the Windows button, type in PowerShell, and open PowerShell.
[00:02:20]
And then I want you to run this command right here. Multipass launch name secondary. Like that. Okay, this is actually going to go and create a second VM on our computer. And you can see here I have a primary one that's already running, and it's gonna create a second one called secondary.
[00:02:46]
Not something you necessarily need to care a whole lot about. Multipass is just a tool that you use on your computer to kind of simulate a cloud environment. But yeah, that's how we're gonna get it working. This will take maybe, I don't know 30, 45 seconds to get up and running, okay?
[00:03:04]
And then here we can say multipass shell secondary. And you can see here, I'm now connected to ubuntu@secondary. And you can actually see up here as well, secondary up here, you can also say open shell up there, and you can connect to that. Cool, so I have a totally separate secondary environment.
[00:03:29]
You can see here I have ubuntu@primary and ubuntu@secondary. You can imagine these being two separate computers, like maybe primary is my computer that I have at home, and secondary is one on the cloud. Or maybe they're two different VMs in the cloud. But, yeah, they're two different computers basically running on our computer.
[00:03:45]
So, the first thing we're gonna do on secondary, is we're gonna add a new user, something that we've already done before. So I'm gonna say sudo useradd. We're gonna give it a default shell so that before, remember we were using that weird dash shell. This time we're gonna use bash, so you can say, -s/bin/bash, and this will have it start bash instead of that weird dash one.
[00:04:11]
Want to give a -m which will give it a, it creates the user a home folder for you, so you don't have to create it for them. We're gonna give it the group of Ubuntu, so it has all the same permissions as Ubuntu, and we're gonna name the user, Brian.
[00:04:29]
Okay, pretty straightforwards so far. And now we're just gonna change Brian's password. Something super simple, okay? And so now if I say switch users Brian, you can see here, I'm here as Brian, you can see that I am in Ubuntu, and I was running bash as my shell.
[00:04:55]
And it also created a home directory for Brian as well.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops