• Thanks for participating in our community, All Forum members are allowed to create threads and posts. Resources posted here should be CLEAN and SAFE. Do not post “offensive” posts, links, or images. Remain respectful at all times.

Access Virtual Private Server (VPS) via SSH key

nowake

Forum Guru⚙️
Staff member
Code Wizard
SEO Samurai
Programmer
Debug Doctor
WP Alchemist
May 15, 2024
185
38
28
Rhodesia
nowake.co
leb-ssh-tut-6.jpg

How to Access Virtual Private Server (VPS) via SSH key?

To access a Virtual Private Server (VPS) via SSH key, you need to follow these steps:

1. Generate SSH Key Pair: If you haven't already, generate an SSH key pair on your local machine. You can do this using the `ssh-keygen` command. It will create a public key (`id_rsa.pub`) and a private key (`id_rsa`) in the `~/.ssh/` directory by default.

Bash:
ssh-keygen -t rsa -b 4096

2. Copy Public Key to the VPS: Once you have your SSH key pair generated, you need to copy the public key to the VPS. You can do this manually by copying the contents of the `id_rsa.pub` file and appending it to the `~/.ssh/authorized_keys` file on the server. Or, you can use the `ssh-copy-id` command:

Bash:
ssh-copy-id username@your_vps_ip

Replace `username` with your username on the VPS and `your_vps_ip` with the IP address of your VPS.

3. SSH Login with Key Pair: After copying the public key, you should be able to SSH into your VPS without being prompted for a password:

Bash:
ssh username@your_vps_ip

If you set a passphrase for your SSH key pair during generation, you'll be prompted to enter it. Otherwise, you'll be logged in directly.

4. Secure SSH Configuration (Optional): For added security, you might want to configure your SSH server to disallow password authentication and only allow SSH key authentication. You can do this by editing the SSH configuration file (`/etc/ssh/sshd_config`) on your VPS and setting:

Bash:
PasswordAuthentication no

After changing this setting, remember to restart the SSH service:

Bash:
sudo systemctl restart ssh

By following these steps, you should be able to securely access your VPS using SSH key authentication.
 
Last edited:

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu

  AdBlock Detected
Sure, ad-blocking software does a great job blocking ads, but it also blocks you from helping us improve our website. We really work hard to bring you paid content Free, the least you can do is disable your AdBlocker. Thanks!!