Terug naar het artikeloverzicht

How to connect to a webserver via SSH

Code on a computer screen
Photo by Gabriel Heinzer on Unsplash

If you are reading this article, chances are you are new to the world of web administration, or you are looking back for reference. Either way, it's always a good idea to check back now and then to refresh some of those web admin skills.

Recently, I've been inspired to create a short series of articles that highlight some of the basic aspects of working with web servers. I usually write for people who already have a working knowledge of web servers, so I hope this new series helps you on your journey to webmaster stardom.

First, there are two basic ways to connect to a web server via SSH (well, three): using Windows, macOS, or Linux (Ubuntu, Linux Mint, etc.). I say two because using SSH on macOS and Linux is basically the same.

To create these guides, I use a dedicated server from Spin Servers.

Windows

There are multiple ways to use SSH on Windows. The most popular (and my favorite) is a program called PuTTY, a free SSH and Telnet client for Windows.

Windows 10 and 11 also include a built-in OpenSSH client, so you can run the same ssh command shown in the macOS & Linux section below from PowerShell or Command Prompt.

PuTTY configuration window
PuTTY configuration

The PuTTY interface is simple to operate. Paste your server's IP address into the Host Name (or IP address) field, enter the port number (the default SSH port is 22), then click Open.

The first time you connect, PuTTY shows a security alert about the server's host key. This is normal for a new server. If you see it for a server you have connected to before, it means the server's key fingerprint has changed: either the system admin changed the key, or someone may be impersonating the server to get you to connect to a malicious SSH session.

PuTTY security alert about the server host key

You can save your server's connection details by filling in the information and clicking Save. This adds the server to the stored sessions list, which is very helpful when you manage multiple servers.

PuTTY then opens a terminal asking for a username and password. If you are connecting to a fresh OS install, your web host will most likely send you your login credentials. The username is almost always root.

Once you have accessed your server via SSH, you can administer it according to your needs.

macOS & Linux

Connecting to a web server via SSH on macOS and Linux is similar, as both use the system's command line.

On macOS, you can open Terminal in either of these two ways:

  • Click the Launchpad icon in the Dock, type Terminal in the search field, then click Terminal.
  • In the Finder, open the /Applications/Utilities folder, then double-click Terminal.

On Linux, we'll use Ubuntu as an example. Pressing Ctrl+Alt+T opens the command line.

Once you are in an active terminal session, use this command to start an SSH connection to the target server:

ssh username@ip-address

If you want to connect to a port other than 22, use:

ssh username@ip-address -p [portnumber]

If you are logging into a fresh OS, your username is most likely root, and the password was set during the OS install or inherited from a previous install. You can normally reset the root password in your web host's client area.

The first time you connect, you will see a warning that the authenticity of the host can't be established, along with the server's key fingerprint. Type yes to continue. As with PuTTY, if this warning appears for a server you have connected to before, the server's key has changed: either the system admin changed it, or someone may be impersonating the server.

In this guide, you have learned a couple of ways to connect to a web server (or localhost) via SSH on Windows, macOS, and Linux. The next step is to learn some commands and basic server security.


If you have questions about any of our services, please contact us via email at [email protected] or by using our live chat at spinservers.com.

Spin Servers is a US-based provider of dedicated servers & affordable private cloud solutions. Our motto is to let you "spin up servers" fast, seamlessly, and affordably.