Connecting and Configuring SSH on VPS
Secure SSH Access to Your AlexHost VPS
Why secure SSH on AlexHost? SSH is your key to managing an AlexHost VPS securely, letting you control your server remotely with confidence. AlexHost’s high-performance VPS, with NVMe storage and DDoS protection, pairs perfectly with SSH for fast, safe access to your WordPress, Git, or custom apps. This guide walks you through connecting to your VPS via SSH and locking it down for top-notch security.
1. Prerequisites
Before you start, ensure you have the following:
- VPS Hosting: A VPS with an operating system installed (Linux distributions are common).
- SSH Client: An SSH client installed on your local machine (Linux and macOS have built-in SSH clients; Windows users can use PuTTY or Windows Terminal).
- Server IP Address: The IP address of your VPS.
- Username: Typically, the default username is root or another user with sudo privileges.
2. Connecting to Your VPS via SSH
Step 1: Open the Terminal or SSH Client
On Linux or macOS:
- Open the terminal.
- Use the following command to connect to your VPS:
Replace username with your actual username (e.g., root) and your_server_ip with the IP address of your VPS.
On Windows using PuTTY:
- Open PuTTY.
- Enter the IP address of your VPS in the “Host Name (or IP address)” field.
- Ensure the port is set to 22 and the connection type is set to SSH.
- Click Open to connect.
Step 2: Enter Password
When prompted, enter your password. If this is your first time connecting, you may see a message about the server’s authenticity. Type yes to continue.
3. Configuring SSH for Secure Access
To enhance the security of your SSH connection, consider the following configurations:
Step 1: Change the Default SSH Port
Changing the default SSH port (22) to a non-standard port can reduce the risk of automated attacks.
- Open the SSH configuration file:
- Find the line that says #Port 22 and change it to a different port, e.g., Port 2222. Remove the # to uncomment it.
- Save and exit (CTRL + X, then Y, then Enter).
Step 2: Disable Root Login
For better security, it is advisable to disable root login via SSH.
- In the same sshd_config file, find the line PermitRootLogin yes and change it to:
- Save and exit the file.
Step 3: Set Up SSH Key Authentication
Using SSH keys for authentication is more secure than using passwords.
Step 1: Generate SSH Key Pair
On your local machine, run the following command to generate an SSH key pair:
Follow the prompts to save the key (default is ~/.ssh/id_rsa) and set a passphrase for added security.
Step 2: Copy the Public Key to Your VPS
Use the following command to copy your public key to your VPS:
This command will prompt you for your password and copy the public key to the ~/.ssh/authorized_keys file on your server.
4. Restarting SSH Service
After making changes to the SSH configuration, restart the SSH service for the changes to take effect:
5. Testing Your Configuration
Step 1: Test SSH Key Login
- Disconnect from the server by typing exit.
- Reconnect using your SSH key:
You should be able to log in without entering your password if you set up SSH key authentication correctly.
Step 2: Ensure Root Login is Disabled
Try to log in as root:
You should receive a message indicating that root login is not permitted.
Conclusion: Lock Down Your AlexHost VPS with SSH
SSH is your secure gateway to managing your AlexHost VPS, perfect for running WordPress, Git, or custom apps. Connect easily, secure with key authentication, and harden with custom ports and Fail2Ban. AlexHost’s NVMe speed and DDoS protection ensure your SSH sessions are fast and safe. Set it up, back up keys, and manage your server like a pro—AlexHost has you covered!