• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Linux SSH Key Setup Linux & Windows

OT Madness

Banned User
Joined
Dec 29, 2017
Messages
8
Reaction score
3
This was a little confusing for me to figure out so I thought I'd share my experience to help those that might be confused by this process. This is probably one of the most important things you can do for your server.

If you are a windows user then follow this guide to generating ssh keys then you can skip ahead to VPS - OVH of this tutorial (if that is your host).
Using PuTTYgen on Windows to generate SSH key pairs | SSH.COM

Local Machine
To generate ssh keys on linux open a terminal (assuming you are using debian) and update the system (always update before you do anything inside of the terminal).
Code:
sudo apt-get update

Then type this command to see if you have any keys already generated in your local machine.
Code:
ls -a ~/.ssh
The goal of running the command above is to look for 2 files 1 named id_rsa (private key) and the other named id_rsa.pub (public key). If they aren't listed then don't worry about it, we'll generate them in the next step.

Now type this terminal command below which will ask you for a name of the file to save as just hit enter don't bother giving it a name then it will ask you for a password which you should set, then it will ask you to confirm the password and that will be it.
Code:
ssh-keygen -b 4096 -t rsa

To view the ssh public key we just created type the command below and this will print to screen a big mess of letters, numbers and other characters that starts with ssh-rsa. You can do the same for the private key as well, just remove the extension .pub Copy the key from the terminal by selecting the text and then hold CTRL + Shift + C
Code:
cat ~/.ssh/id_rsa.pub

VPS - OVH
Sorry I am not familiar with other vps's so hopefully you can adapt these instructions to your host provider.
Go to your control panel and in the upper right corner you should see your name click on that and a drop down will appear, click on My Account. Then a new side bar will show up to the left, look for My SSH keys click on that you now you will see this. Click on the Add an SSH key button and then click Dedicated.
ssh.png


A new window will pop up asking for ID and Key (the ssh public key). I named mine my website address. Just paste the ssh public key that you copied in the key window. Click confirm and you are done. I recommend reinstalling the operating system after completing this part.
crop.png


Host Machine

This setup can be done with both root (in case reinstall is not an option) or as otsmanager, you can also use the same keys for both users. Open a terminal and type, replace your ip here with your vps's ip address.
Code:
ssh otsmanager@your ip here

Then type the command to make a new directory name .ssh in your home directory. Which you will give the directory writeable permissions.
Code:
mkdir ~/.ssh
chmod 700 ~/.ssh

Then you will type, this command will open a text editor within the terminal now take your public key and paste it in the window. To paste in a Linux terminal hold CTRL + Shift + V. Then hold CTRL + X to exit nano and save the file.
Code:
nano ~/.ssh/authorized_keys

Now while still in the terminal type the command below, this restrict the permissions to authorized_keys. Type exit to exit the connection with vps then just reconnect to your vps. If everything went well it should ask you for the password that you set when you created the ssh keys.
Code:
chmod 600 ~/.ssh/authorized_keys
 
Last edited:
Back
Top