This course has been updated! We now recommend you take the Full Stack for Front-End Engineers, v2 course.
Transcript from the "Basic Server Setup, Updating and User Permissions" Lesson
>> Jem Young: Everybody here should have a way to SSH into a server, and hopefully you have an SSH key. If you don't, shame on you, you should have done it for the first one, but you should have at least one lying around. So for the first part we're gonna create a server.
[00:00:13] We're gonna do pretty much everything we did in the first course, but much, much faster. Because I don't have to explain anything. And you'll see that once you do it, it's actually really easy. A few people here were saying, it was so great bringing up the server, because it was so much easier than I thought.
[00:00:28] And it is, sort of, [LAUGH] as long as you follow the paved road on how to do it. So let's go ahead and bring up the server. So on DigitalOcean, or Amazon, or whatever your preferred provider. I like DigitalOcean, they have probably one of the best user interfaces for bringing up the server.
[00:00:45] Amazon is pretty ugly, but use whatever you want. We'll be using DigitalOcean today. We're gonna create a new Ubuntu server. Be sure to use Ubuntu 16.04 dot whatever, doesn't matter. If you're watching this a year from now, it doesn't matter, 16.04 is the LTS version. That means it's gonna be supported for at least two years.
[00:01:04] That's the version we're gonna stick with today. We used 16.10 in the last class, only cuz the node set up was slightly easier, but that's now been deprecated. So now we're all gonna use 16.04, cuz I know it will be around for at least two years. And when you bring up that server be sure to use an SSH key.
>> Jem Young: And I'll give you a minute, and then I will go ahead and do that. Just to make sure we are all doing the same page, but it's fairly straightforward in DigitalOcean.
>> Speaker 2: Can I use a local server on my machine?
>> Jem Young: Yeah totally, yeah. I found the satisfaction of creating something that you can show your mom or whoever.
[00:01:42] But, yeah you can use a local server. You will run into trouble when we get to the HTTPS part, so you won't be able to install a certificate on your local machine. You can, but it won't be a real certificate, it'll be kind of a fake certificate. So I would encourage you to bring up a new server, but it's your call.
[00:02:02] If you've already brought up a server before on 16.04 you can chill. I kind of encourage you to bring up a fresh one, just in case you installed something strange. Cuz again, we're all following the same path, and I don't know what you did before. But if you have confidence that I can fix it, that's cool too.
[00:02:19] I believe in independence. You don't have to listen to every word I say. Actually, you do. You're kind of stuck here [LAUGH]. And while that's happening, it takes a few seconds to bring up a new server, if you have a domain, if you've already bought one, they're pretty cheap now, there are some for like $1.
[00:02:35] Point your domain to the new server. We have to do it now ahead of time. We're probably going to cover HTTPS after lunch, but we want to do it now, because the, yeah, why do we have to do it? I explained this on the first one.
>> Speaker 2: It takes time to resolve on the physical machine sync up.
>> Jem Young: Yes, DNS takes time to resolve across the entire world, so we're gonna point the domain to a new server now, and there's a link to part one if you need to remember how to do that. But we wanna do that now, because we're gonna create HTTPS, we're gonna create that nice, cool lock arrow for your domain name.
[00:03:09] But we have to do it now. Okay, just gonna do a quick show of how we do that. So if anybody wants to bring up, hopefully you follow the steps already. But you click Create Joblet in DigitalOcean and pick your data center. Pick whichever one is closest to you, naturally.
[00:03:30] We're kind of in the middle, so let's pick New York. It's probably slightly faster than San Francisco. And if I want to add the ssh key, we just click that and then you give it a name which I've already done. I already have one that I brought up earlier just to make sure.
[00:03:45] Actually, just like I point my IP address to my new domain cuz I'm lazy. Super lazy. And once you're in your server as root, you log in as root. Let's give you a heads up. Don't move on to the next step yet. We will do it all together.
[00:04:03] As you will probably remember when you create the ssh key, there, why won't you go, there we go. If you say pwd, that's print working directory, this is all my local machine now, I'm not logged in to a server yet. I always switch to the ssh folder because it's slightly shorter for me to type.
[00:04:20] So to remember how to log in is ssh -i to use my key. It's my private key I'm using, and I'm gonna say root. Gotta remember what my server IP is. Just gonna copy that.
>> Jem Young: Root at, [NOISE], and yes. Right, that was easy, right? We spent so much time setting up a server and talking about how to set up a server and then you do it in three minutes.
[00:04:50] That's what it's all about, it's getting faster and faster and faster. Everyone logged into their server? You will have a hard time if you're not logged in to your server past this point.
>> Jem Young: Okay, no response is a yes. Let me make this bigger, all right. All right, can you see in the back?
[00:05:19] All right, cool, perfect. All right, step 4. Let's update our server, how do we update our server? Remind me, I'm getting old, I forget things.
>> Speaker 3: Apt update.
>> Jem Young: Yes, so we don't have to sudo, because we're already as the super user, so we're just gonna say apt update, all right.
[00:05:43] Next, let's actually, we just pulled down everything. Think of, the correct analogy is think of like a get repo, we're just pulling it down but we haven't merged anything yet. We just have references to the things we want to do. So let's say apt upgrade. Yes, we're gonna upgrade all of our local libraries.
[00:06:05] Right now, you're sitting there thinking, you're thinking, why am I here on Friday? I could do like so much better things. That's what you're thinking. But, and the second thing you're thinking is, why are we using apt and not apt-get, cuz we've always used apt-get. In fact all my slides, install this one, doesn't really matter.
[00:06:23] All of my slides on the last one were all apt-get. Well, I'm glad you were thinking that, cuz I was thinking that too. Apt-get is, think of it as the programmer's way of updating a repository. It's consistent, it doesn't have any fanciness to it. It's always gonna have the same style of output, so you can programmatically create scripts against it.
[00:06:42] Apt is the friendlier user, the friendlier user interface way of creating your repo's. They do the same thing, except apt can change in the future. It's just a little bit nicer. It has those nice progress bars that apt doesn't have. That's pretty much the key difference, but I'm glad you were thinking that cuz I was thinking that too.
[00:07:01] All right, let's add a new user. You can call it test, you can call it friend or master, it doesn't matter. I'm gonna say test, just for the sake of simplicity. So adduser test. Let me give it a pretty simple password for this time around.
>> Jem Young: Next, let's make sure that our new test user has sudo permission.
[00:07:26] So we're gonna say, usermod -aG sudo test. Awesome, so our test user now has sudo permissions. So let's switch over, su, switch user, test. And I'm just gonna cd, that's my home directory. I mean, /home/test, or slash home, whatever you made your user. And I just want to check to see that I have permission.
[00:07:55] So I'm going to say /var/log/auth.log. It's gonna ask for your password. All right, so I can sudo things. Pretty important. Once we, we're gonna lock the root account so you can't log in as root anymore. So you wanna make sure you have sudo access, otherwise you're gonna have a bad time.
[00:08:12] And you'll start over again.