课程: Learning SFTP
Lab setup: Server configuration
- [Instructor] In this video, we'll take a look at three ways of setting up a server to use with SFTP. If you already have a server, you don't need to follow these steps. If you don't have a server, I recommend you watch this video all the way through first to get an idea of the options available. Generally speaking, there are three ways we might set up a server. We could create a virtual machine for the server to run in, we could set up our server using a real computer, or we could start up a server in the cloud. Usually a server we connect to with SFTP will be a Linux server. That's not always the case, but it's by far the most common case, so that's what we'll use here in this course. I recommend using the Ubuntu Server distribution because it comes with the OpenSSH server software already installed. And when we set up a server with a user account, we'll be able to use that user account to log in to the server remotely. So with Ubuntu Server, there's not really any additional setup to do on the server after the installation process, and that keeps things a bit easier as we set up a server to use for practice. This is also the case with many other server-oriented Linux distributions. Another option is to use an existing Linux system to act as our server, and if we do, we'll need to install the OpenSSH server software package using the appropriate package management tools for our platform. For more detail on doing that, be sure to take a look at my course called "Learning SSH" here on LinkedIn Learning. On the server, we'll need to have a local user account, which we'll use to log in remotely. We might have a username and a password, or we might have a username and a cryptographic key, the private key portion of a key pair. And the server will need to allow access to the SSH service through its firewall. In this course, I'm using a virtual machine on my lab network because that's how I like to set up my practice space. But as one of my favorite fitness instructors says, "I make suggestions. "You make decisions." You should choose the lab setup that you're comfortable with and which fits your needs. Because this course is focused on using SFTP, not on server management, I'll cover each of these three options briefly and point you to resources you can use if you want to explore each option in more detail. The details of each of these won't be on the test. Each of these three options will achieve the same goal. When we're done, we'll have a server we can connect to using SFTP and we'll have user credentials we'll use to make that connection. The only difference is how you choose to set up your lab. First, let's take a look at using a virtual machine for our practice server. A virtual machine is a protected space where a full operating system can run, and it behaves like a real computer running on your existing computer, but anything that happens within the virtual machine doesn't affect your real computer. That makes virtual machines great for learning. I prefer to use the VirtualBox hypervisor software to set up virtual machines, and that's available for free from virtualbox.org. I have that installed here on my system. For this quick setup, I'll skip a lot of the details of the process, but if you want to learn more about VirtualBox and virtual machines, take a look at my course, "Learning VirtualBox" here on LinkedIn Learning. To set up a virtual machine, we'll need an operating system installer, and I've downloaded Ubuntu Server from ubuntu.com. Then, in the VirtualBox Manager software, I'll create a new virtual machine, either by clicking the New button here or by going to Machine and choosing New. I'll give my machine a name, provide its memory and storage, and once that's created, I'll go into its settings and make a change. I'll find the Network area, and under the Attach to section, I'll change this to Bridged Adapter. This means that my virtual machine will participate on my local network just like a real computer. It'll share the Ethernet interface here on my system. Then I'll click on Storage, and under Controller: IDE, I'll click Empty. Here on the right, I'll click this blue CD icon, and then select Choose disc file. I'll browse to where I downloaded the installer image, select it, choose Open, and then click OK. With the changes made, I'll click the start button. This will boot into the installer. To make things here on my screen larger, I'll click View, choose Virtual Screen 1, and Scale to 200%. And I'll maximize the window. Using Enter and the arrow keys, I'll go through the setup fairly quickly, but I will point out two important items. When it comes time to set up the network address, I'll leave this option set to dynamic, or DHCP, so the system gets an address from the local network. Ordinarily we'll want a server to have a fixed IP address, one that isn't going to change, but setting that up takes us even further from focusing on SFTP, so we'll stick with a dynamic local address here for now. Take note of what address this shows on your system. That's the address you'll need to use to access the server later in the course. In my case, it's 10.0.1.4, but yours will probably be different. I'll continue. And as the setup continues, we'll be asked which services we want to enable. I'll make sure SSH server is enabled here by selecting this item and pressing Spacebar. This is what will allow us to access this system using SFTP. I'll continue. When the setup is complete, I'll restart the system. And when it comes up, I'll log in using the username and password I set during the installation process. Here I can use the command ip space a to check the system's IP address. This could change over time, so it's good to know how to check it. This is the address we'll use to connect to this server from our SFTP client. And again, yours will probably be different than this one. This system will need to be booted up in order to be used as a server, but when we're done using it, we can tell it to shut down by typing the command poweroff. And we can come back to restart the system if we want to practice more. We don't need to log in to the system locally for it to work as a server, though. As long as it's up and it's running, it should fulfill its duties. To set up a physical computer as a Linux server, we'll need a computer that we can erase and install a new operating system on. My course about building an Ubuntu server has more information about setting up and running a server on physical hardware, if you'd like more details about this option. And again, we'll take a very brief look at setting up a system like this, here. To get started, I've downloaded the Ubuntu Server installer image from ubuntu.com and I've put it on a USB drive that I'll use to install it on my computer. I'll plug in my installer disk and start up my computer. On this system, I need to press F10 to get to a boot menu, where I can select how to start the system. I'll do that so I can start from the USB installer. I'll go through the installation process, and when I'm asked about the network settings, I'll choose Automatic DHCP so the server gets an address automatically from the local network. As we saw in the virtual machine setup, we'd normally want a server to have a static address, but setting that up is more involved than we need to worry about here. So remember this address. In my case, this system got the address 192.168.0.38. Yours will probably be different. So remember your address, and that's where we'll be able to communicate with this server later in the course. I'll continue through the setup process. When I'm prompted about what services to enable, I'll want to make sure that SSH server is selected here because that's how we'll access the server using SFTP later in the course. And when the process completes, I'll restart the system. Once it's up and running, it's ready to be used as a server. I can log in here using the username and password I set up during the installation process, and I can check this system's IP address with the command ip space a to see if it's changed. Mine is the same as it was during setup. When I'm done using the system, I'll turn it off with the command poweroff. A third option for practicing with SFTP is to use a cloud server set up on the internet. Later in the course, I'll use a system running on Azure, but you could use a different host like DigitalOcean, Linode, AWS, and so on. Running servers in the cloud comes with some cost and security obligations which you'll be responsible for. Because the setup of a cloud server varies widely across the different providers, I won't go through the steps of setting one up here, but if you choose to, be sure you know the address and the username and password of your account, or if your host uses keys instead, be sure you have the private key for the account you'll need to use. That's what we would use in place of a password as we move through the course. Again, this has been a very brief look at how to set up a server with SSH access in a few different ways. If you need more details, be sure to explore our courses, which focus on each kind of server. To learn more about setting up a virtual machine, check out my course, "Learning VirtualBox" here on LinkedIn Learning. If you'd like to set up a Linux server of your own, take a look at "Building an Ubuntu Server". And if you choose to use a cloud host, look for courses here that cover the hosting service of your choice.