Pinterest Stumbleupon Whatsapp
Advertisement

Server management remains a necessary and occasionally cumbersome task. It’s especially difficult with remote servers or headless servers. Thankfully, there’s Secure Shell (SSH). Secure Shell is a network protocol that allows for network services to run over an unsecured network.

SSH boasts a ton of functionality. There’s a reason it’s a go-to for remote server management. Learn how to remotely manage a Linux server via SSH, from connection to installing software and file transfers.

What Is SSH?

SSH stands for Secure Shell. It’s a cryptographic network protocol. Using SSH, you can gain terminal access and perform various command line functions. There are also means of managing a Linux server with graphical access. This is really useful for file transfers, particularly when you don’t want to or can’t remember an exact file path.

When using SSH to manage a remote Linux server, you’ll need a few items. First, you’ll need to prepare your server to accept SSH connections. On the devices you’ll be connecting from, you’ll require some sort of SSH software. To log into a server with SSH, you’ll need to know the IP address of the server. However, logging in via SSH with an IP address only works if you’re on the same local network as the server. If you’re outside your network, you can set up a port forward to access a server with SSH from anywhere. You can learn more about SSH in this beginners guide to setting up SSH on Linux Beginner's Guide To Setting Up SSH On Linux And Testing Your Setup Beginner's Guide To Setting Up SSH On Linux And Testing Your Setup Arguably one of the most important Linux utilities to learn is SSH as you can control a different machine as if you were sitting directly at it. We'll take you through a basic installation. Read More .

Preparing Your Server to Accept SSH

Before you begin managing your Linux server via SSH, you’ll have to prepare your server to allow SSH connections. I have a headless dedicated Plex media server. Lacking a monitor and peripherals, I use SSH to manage my server. When installing or updating software and transferring files, I simply SSH into my server. My exact set up is a ThinkServer TS140 running Ubuntu 16.04 LTS. Depending on your hardware and Linux distribution, prepping for SSH may vary slightly.

To prep your Linux server to accept incoming connections, you’ll need to install a remote login tool for the SSH protocol. One of the most common is OpenSSH. On Debian-based distributions, OpenSSH is available via the main repositories. Open a new terminal (Ctrl + Alt + T) and enter the following command:

Advertisement
sudo apt-get update

This performs an update and ensures you’ve got the latest repositories. Before proceeding to install OpenSSH, also check for any upgrades. In a terminal, run:

sudo apt-get upgrade

Nix-Server-Upgrade
Once you’ve updated and upgraded, open a new command line and enter:

sudo apt-get install openssh-server

Nix-Server-Install-OpenSSH

Configuring Your Server SSH Settings

After Open SSH has been installed server side, you can edit basic configuration info. Pull up a fresh terminal and enter the following string to open the SSH config file:

sudo nano /etc/ssh/sshd_config

SSH-Config
Here you can specify various settings. By default your SSH server will operate on port 22. So, for instance, you can manually change the port from 22 to a port of your choosing. Additionally, you may increase security by entering a maximum login number. Under Port, find the line MaxAuthTries. You can input any number here. So to make a maximum login attempt count of four, enter:

MaxAuthTries 4

After installing OpenSSH, the SSH server should be running. But to check, simply open a terminal and run:

sudo service ssh status

SSH-Status-Running
This should return a message that SSH is enabled. To start SSH, open a command line and enter:

sudo service ssh start

And to stop SSH from running, run:

sudo service ssh stop

Remotely Accessing a Linux Server via SSH

Now that SSH is installed and running, you can connect remotely. If you’re logging into a Linux server remotely, you’ll need the IP address of the server. This should be 192.168.0.x. Armed with the Linux server IP address, you’ll also need a means of logging in via SSH from a different machine. There are several methods for logging in remotely with SSH.

Using SSH on Unix-Based Operating Systems

If you’re using a Unix-based system like Linux, macOS, or FreeBSD, SSH is available in the command line. In a terminal, run:

ssh [remote host]

…where [remote host] is the IP address you’re accessing. If your username differs on the remote system, you can specify the exact username by entering:

ssh [remote username]@[remote host]

After entering this, you’ll be asked if you want to continue connecting. Then you’ll be prompted to enter your username and then asked for your password.

SSh-Y-N-Nix

Alternately, if you’d like to skip the command line altogether, you can log into your Linux server via the network. On a Linux machine, navigate to Connect to Server and enter your ssh://[IP address]. You’ll be asked to provide your username and password.

SSH-Connect-to-Server

The main advantage of this method is that you’ll have complete graphical folder navigation. This is called SSH File Transfer Protocol, or SFTP. This makes file transfers much easier. Since my Linux server is a dedicated Plex server, unless I’m performing updates, I usually use SFTP.

SSH With PuTTY

If you’re using a PC or Mac, you’ll need an SSH client. PuTTY is probably the most well-known SSH client. Install PuTTY on your PC, macOS, or Linux machine. With PuTTY open, look under Session and in the box labeled Host Name, enter your IP address. Make sure to specify the correct port. If using the default, leave this as 22.

PuTTY-Nix-Host-Name

Now you should see a terminal with a login prompt. Enter your Linux server username here.

Once you’ve entered your username, you’ll be prompted for a password if you’ve got your Linux server password-protected. Enter that and you should see a welcome message with information about your system and a command line like you’d see on your Linux server.

Alternate SSH Clients

Although PuTTY remains the most popular SSH client, there are loads of alternatives. My top pick is Bitvise (Windows only). The reason? It includes not only the command line interface for remotely managing a Linux server via SSH, but SFTP capabilities. Thus, it’s perfect for both file transfers and general management. When I need to simply update or perform a reboot, I use Bitvise SSH Client for command line access. But for file transfers, I use the graphical interface.

Like with PuTTY or starting SSH via the command line on Linux, you’ll need to enter your IP address, username, and password.

Bitvise-1

You’ll recieve a prompt asking if you’d like to accept the session. You can accept for just that session or save for future use. After that, you’ll be asked to input the password of your Linux server that you’re remotely managing.

Bitvise-2

Plug that in and Bitvise will open both a command line and graphical SSH window.

Bitvise-4

The SFTP window makes managing file transfers really simple, plus there’s the traditional SSH command line for lots of functionality.

How You Can Manage a Remote Linux Server With SSH

Okay, great! SSH is configured both on the server and the device you’ll use to manage your server. So, what can you actually do? Anything that’s possible with the Linux command line. Some common tasks you may preform are software installs, updates, reboots, copy files, and even run GUI applications. For example, you can copy files with the following commands:

scp [remote host]:[local file] [destination directory]
scp [local file] [remote host]:[destination directory]

Installing software merely means plugging in the proper command. When I installed Plex on my headless TS140 via SSH for example, I merely entered:

sudo apt-get install plexmedia server -y

Similarly, to say create a WordPress server, you would just follow the install details but via a SSH command line.

What you do likely depends on the server and what it’s used for. As I run a headless dedicated Plex server, most of what I use SSH and SFTP for is file transfers with occasional software updates. I’ve also used SSH to access log files and run benchmarks to test CPU performance. If you’re running a web server, you may wish to backup your website using the SSH command line How To Backup Your Website Through SSH Command Line How To Backup Your Website Through SSH Command Line Backing up your website or blog can be an expensive and arduous task, requiring a variety of plugins, or additional plans from your hosting provider - but it needn't be really. If you have SSH... Read More . Check out this quick primer to the Linux command line A Quick Guide To Get Started With The Linux Command Line A Quick Guide To Get Started With The Linux Command Line You can do lots of amazing stuff with commands in Linux and it's really not difficult to learn. Read More , as well as these three sites to help you evolve into a Linux command line master Top Websites and Books to Transform You into a Linux Command Line Hero Top Websites and Books to Transform You into a Linux Command Line Hero The Linux command line is an extremely powerful tool -- but it can also be intimidating. Use these websites and books to get a handle on it. Read More .

SSH: Finding the Remote

If you’re running a Linux server, SSH is a superb means of managing it remotely. You retain full command line control, and can even run GUI apps and perform file transfers. There are near limitless possibilities to what you can accomplish when managing a remote Linux server via SSH. You can set up a file server, media server, Linux game server Everything You Need to Build a Game Server on Linux Everything You Need to Build a Game Server on Linux Since its inception, gaming has almost always been more fun with multiple players, a practice that has moved online. To host an online tournament, you'll need to setup your own game server, using Linux. Read More , and more. You can even manage a headless Raspberry Pi Setting Up Your Raspberry Pi For Headless Use With SSH Setting Up Your Raspberry Pi For Headless Use With SSH The Raspberry Pi can accept SSH commands when connected to a local network (either by Ethernet or Wi-Fi), enabling you to easily set it up. The benefits of SSH go beyond upsetting the daily screening... Read More server using SSH. What’s more, many SSH client programs are cross-platform.

How are you using SSH and what sort of server are you managing?

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Korla Plankton
    March 29, 2017 at 4:54 am

    Putty makes me want to tear my hair out. I haven't tried Bitvise but Cygwin is worth installing if only for the ssh client (it also makes windows suck slightly less.)

    OS X already has an ssh client. If you're going to be managing linux from the command line, you might as well do it from OS X's command line.

  2. Fischi
    February 8, 2017 at 12:14 pm

    This sentence is more or less nonsense:
    "If you’re using a PC or Mac, you’ll need an SSH client. "
    As of course you need a ssh client ON EACH system but as you wrote some paragraphs above on a Unix based systems LIKE MacOS / OS X the ssh client is built in and isn't necessary to install such a like Putty for it.