Lagless.gg Docs

Configuring SSH

Learn how to securely configure SSH access on your VPS for enhanced security and peace of mind.

Creating your key

SSH (Secure Shell) is the standard protocol for securely accessing remote servers. Properly configuring SSH on your VPS is essential for maintaining security and preventing unauthorized access. This guide will walk you through setting up secure SSH access using key-based authentication and hardening your SSH server configuration.

On Your Local Machine

  1. Open your terminal and generate a new SSH key pair:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  1. When prompted, accept the default location or specify a custom path.

  2. Optionally, add a passphrase for additional security.

Adding a Passphrase

By setting a passphrase, you have an additional layer of security on your ssh key however if you lose or forget your passphrase, you'll need to regenerate a new SSH key.

Add your Public Key to VPS Panel

Go to the directory you saved your SSH key to and copy the file ending in .pub. Make sure you copy your public key, not your private key. One way to confirm this is by looking at the end of your public key file, your comment should be at the very end.

From your VPS Panel, select SSH Keys at the top then Add Key. Give your SSH key a name and paste the public key into the box then save.

Client panel services

Adding SSH key manually (on your own)

If you prefer not to use the panel or if you are working on an existing server, install the key directly into your account's authorized_keys file.

Method 1: Use ssh-copy-id

  1. Run this from your local machine:
ssh-copy-id -i ~/.ssh/id_rsa.pub user@your-vps-ip
  1. Enter your password when prompted.

  2. Verify login via key:

ssh user@your-vps-ip

Method 2: Manual key deployment

  1. On your local computer, copy the public key content:
cat ~/.ssh/id_rsa.pub
  1. Connect to your VPS using password auth first:
ssh user@your-vps-ip
  1. On the VPS, ensure the SSH directory exists and has correct permissions:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
  1. Append the public key to authorized_keys:
echo "<paste-your-public-key-here>" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
  1. Test SSH login with key. After you ensure your key works, you can proceed to this next article on securing SSH on your machine.

On this page

Ready to get started?

Launch your server today

Get Your Server