DH Bot
We ❤️ DragonHackerz
When working with Linux systems, especially in a network environment, it's essential to establish a secure connection for remote access. SSH (Secure Shell) is a popular protocol for securely accessing and managing Linux systems remotely. In this article, we'll focus on setting up a secure SSH connection on Linux.
Prerequisites
Before we begin, ensure you have the following:
Generating SSH Keys
The first step in setting up a secure SSH connection is to generate a pair of SSH keys. SSH keys provide a more secure way to authenticate users than traditional passwords.
This command generates an ED25519 key pair. You can choose a different key type if needed, but ED25519 is recommended for its security and performance.
Configuring SSH on the Server
Once you have generated your SSH keys, you need to configure SSH on the server to use the new keys for authentication. Edit the SSH configuration file:
Add or modify the following lines:
Save and exit the editor. Restart the SSH service to apply the changes:
Adding Your SSH Key to the Server
Copy the public key (ided25519.pub) to the server and append it to the authorizedkeys file in the user's home directory:
Replace
Testing Your SSH Connection
Now that you have set up your SSH keys and configured SSH on the server, it's time to test your connection.
Replace
If everything is set up correctly, you should be able to access your remote server securely using SSH.
Prerequisites
Before we begin, ensure you have the following:
- A Linux system (Ubuntu, Debian, or any other distribution) with an active internet connection
- A user account with sudo privileges
- SSH client software (OpenSSH) installed on your local machine
Generating SSH Keys
The first step in setting up a secure SSH connection is to generate a pair of SSH keys. SSH keys provide a more secure way to authenticate users than traditional passwords.
Bash:
ssh-keygen -t ed25519 -C "your_email@example.com"
This command generates an ED25519 key pair. You can choose a different key type if needed, but ED25519 is recommended for its security and performance.
Configuring SSH on the Server
Once you have generated your SSH keys, you need to configure SSH on the server to use the new keys for authentication. Edit the SSH configuration file:
Bash:
sudo nano /etc/ssh/sshd_config
Add or modify the following lines:
Bash:
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
Save and exit the editor. Restart the SSH service to apply the changes:
Bash:
sudo service ssh restart
Adding Your SSH Key to the Server
Copy the public key (ided25519.pub) to the server and append it to the authorizedkeys file in the user's home directory:
Bash:
ssh-copy-id user@remote_server
Replace
user with your username on the remote server.Testing Your SSH Connection
Now that you have set up your SSH keys and configured SSH on the server, it's time to test your connection.
Bash:
ssh user@remote_server
Replace
user with your username on the remote server. Enter your password (if you're using password authentication) or the passphrase for your SSH key (if you're using key-based authentication).If everything is set up correctly, you should be able to access your remote server securely using SSH.