Connecting to the Lab Linux Machine via SSH From a Windows Computer

Quick how-to on SSHing into Dr. Bittle's Linux Machine

First Published 2 weeks ago

SSH (Secure Shell) is a protocol for securely accessing remote servers. It will allow you to completely control the remote server using your shell (terminal, command line, whatever your call it)

Basic Info

If you are on a MacOS or Linux, the instructions below are largely the same, only easier. Just open a terminal and type

Prerequisites

Before you begin, you'll need to make sure that the Linux machine you want to connect to has SSH enabled. This is typically the case by default, but you can check by running the following command on the Linux machine:

You should see a message that says "Active: active (running)" if SSH is running on the machine.

The machine that you are ssh’ing from has to be on the campus network, either via VPN or being on-premise

Installing an SSH Client on Windows

On Windows, you can use the built-in Windows PowerShell or the third-party software PuTTY to connect to the Linux machine via SSH.

Option 1: Windows PowerShell

If you're running Windows 10 version 1803 or later, you already have the OpenSSH client installed on your machine. You can start an SSH session by opening a PowerShell window and running the following command:

Replace "user" with the username you want to use to log in to the Linux machine, and replace "hostname" with the hostname or IP address of the Linux machine. As an example, Max’s is :

Option 2: PuTTY

If you prefer to use a third-party client or are your windows version is older, you can download and install PuTTY from the official website. Once you've installed it, open PuTTY and enter the hostname or IP address of the Linux machine in the "Host Name (or IP address)" field. Make sure the "Connection type" is set to SSH, and then click the "Open" button to start the connection.

Connecting to the Linux Machine

Once you've started an SSH session, you'll be prompted to enter your username and password for the Linux machine. If you're using Windows PowerShell, you'll see the command prompt change to indicate that you're logged in to the Linux machine. If you're using PuTTY, you'll see a terminal window open and display a login message.

That's it! You're now connected to the Linux machine via SSH and can run commands, transfer files, and more.

Extras

TMUX

The command you run in an SSH shell will be killed when you disconnect from the machine.

You can get around that issue by running the command inside of a session, among other ways (which I will let you Google)

Using SSH Keys

Using SSH keys is a more secure way to connect to a Linux machine than using a password. It also saves time as you don’t have to enter your password & is the more accepted practice if you are connecting

Generating an SSH Key Pair on Windows

  1. Open the PowerShell or command prompt and run the following command to generate an SSH key pair:

Copy code

You will be prompted to specify a file to save the key and to enter a passphrase. You can press enter to leave the passphrase blank, but this is not recommended from a security standpoint.

  1. The key pair will be saved to the location specified in the previous step. The private key should be kept on the Windows machine and the public key should be added to the Linux machine.

Adding the Public Key to the Linux Machine

  1. To add the public key to the Linux machine, copy the contents of the public key file (e.g., ) to your clipboard.
  2. On the Linux machine, open the file. If the file doesn't exist, create it.
  3. Append the contents of your clipboard to the end of the authorized_keys file and save it.

Using the Private Key to Connect

Once the public key has been added to the Linux machine, you can use the private key to connect to the Linux machine without entering a password.

  • On Windows PowerShell, you will use the ssh command like this:

Copy code

If you add the private key folder to your path, then you don’t need to specify the

  • On PuTTY you will load the private key in to the application and connect as usual.