How to import SSH key from MacOS into Linux VPS

Jim K.

Last Update 3 maanden geleden

Affected Operating System (OS)
1) Almalinux 8, 9
2) Unbuntu 22, 24

Introduction

SSH, also known as Secure Shell, is an encrypted protocol used to adminstate and
communicate with Linux based servers.


When dealing with Linux server, most of the time will be spent in a termial session via SSH.

Using SSH Key is more secure then using password based SSH login.


Here we will assume you already have your own SSH Private/Public key pair.
Below guide will teach you how to add your public key into your Linux VPS for you to access via SSH key.
If you do not have a SSH Private/Public key pair yet, you can go to the respective Knowledgebase article on how to create one.

Procedure

On your Mac

First we need to find out your public key to be able to add it in your server.

For Mac OS, Open your Terminal and go to your SSH folder by enter the following command.


cd ~/.ssh

followed by list out all the files inside.


ls -lth

Your SSH public key will be the one with extension .pub
In this example, we will take the file name as id1_isa.pub

Get the public key by display the file content using cat <file name> command.


cat id1_isa.pub
The key will be output similar to this. Copy this list of code, you will need this later on.

On the Server

Uaing your favourite SSH Terminal, login to your Linux server using the normal password method.
Followed by going into the ssh folder, usually named .ssh


cd .ssh

Edit the authorized_keys file using your favourite editor. For this guide, we will use nano.


nano authorized_keys

Paste the above copied key into the file using [Command] + [V]

Then we will save it by [Control] + [Z]

Press [Y] to confirm saving at the prompt.


You can now login to SSH using your SSH key.

Was this article helpful?

0 out of 0 liked this article

Still need help? Message Us