Connect via SSH to your Linux Server

Photo by Taylor Vick on Unsplash

You have a Linux server and want to connect to it? The common practice is to use a ssh key pair for that. Basically you store a public and private key locally on your machine, upload the public key to your server and than start connecting to it with your private key. No further applications are needed, you just have to use a bash terminal.

Create an SSH key

Start by creating a key pair inside of your .ssh folder. Navigatie to ~/.ssh/:

cd ~/.ssh

and create the key pair with the command:

ssh-keygen

name it, by default the name is id_rsa. If you haven‘t already created keys before you can just hit enter, otherwise enter a new name. Next you will be asked for a passphrase, which encrypts your key and ensures additional security. If you leave it empty the key won’t be encrypted. Retype your passphrase or leave it empty and hit enter again.

Your key pair got created.

You will see now two new files. One with the ending .pub and another with just your chosen name. The .pub file is your public key. You have to upload it on your server. The default file is your private key, keep it secret!

Upload the public key

Next, upload your public key onto your server. The easiest way is to use the ssh-copy-id command. It‘s installed by default. Keep in mind that uploading your public key with ssh-copy-id is only possible if your server has activated password login. Go and copy your server IP address, you will need it and type:

ssh-copy-id <username>@<server_ip>

In case you have created your ssh key with a different name, you have to specify the path by using the option -i

ssh-copy-id -i ~/<path_to_your_public_key> <username>@<server_ip>

Establish a connection

Now you should be able to login via ssh into your server, test it with the command

ssh <username>@<server>

--

--

--

https://erwin-schleier.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Sprint Review & Retrospective

Breadth-first search: find the shortest path

This Week In TurtleCoin (Dec 3, 2018)

Running Docker containers on Maven integration tests

from Evernote to Obsidian 2

How We Scale Out Databases and Get Big Data Queries 6x Faster with a MySQL Alternative

An Ode to Asymptotic Notations

If Cant Change Display Resolution in Window 11! How To Fix it?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Erwin Schleier

Erwin Schleier

https://erwin-schleier.com

More from Medium

Install PhpMyadmin Ubuntu 20.04 Apache2

Linux Terminal Fundamentals. Part 1

A screenshot of the linux terminal and the “mkdir” command

Setting WordPress up using Docker — Geneshki.com

A WordPress install screen

Running a Linux-based NFS Server in Docker on Windows