SSH Access to Linux VM Print

  • ssh, linux
  • 1

Enabling SSH Access on Lightspeed Hosting Linux Servers

By default, SSH access is disabled on Linux servers deployed on Lightspeed Hosting for security reasons.

Before enabling SSH, follow these steps to secure your server and allow safe access.

 


Step 1: Configure the Firewall in the Client Area

Before enabling SSH, it's essential to configure your firewall to allow access only from trusted sources (e.g., your office IP).

  1. Log in to your Client Area.

  2. Navigate to Additional Tools > Firewall.

  3. Under the Firewall tab, click Create Firewall Rule and configure the following:

    • Enable: Set to On to activate the rule.
    • Type: Select In (inbound traffic).
    • Action: Choose Accept to allow SSH traffic.
    • Interface: Set to net0 (public interface).
    • Macro: (Optional) Use predefined settings for common services.
    • Source: Enter your office’s public IP address to restrict SSH access.
    • Destination: Leave as default (your server's IP).
    • Protocol: Choose TCP.
    • Source Port: Leave blank (not needed for SSH).
    • Destination Port: Enter 22 (SSH port).
    • Comment: (Optional) Add a description, e.g., "Allow SSH from Office."
  4. Save the rule and enable the firewall under Firewall Options.

 


Step 2: Create a New User for SSH Access

For security reasons, avoid logging in as root. Instead, create a new user with sudo privileges:

sudo adduser <username>

Follow the prompts to set a password.

Then, grant sudo privileges:

sudo usermod -aG sudo <username>
 
 

Step 3: Enable SSH Authentication

SSH authentication can be configured in two ways:

  • (Recommended) SSH Key Authentication – More secure and preferred over passwords.
  • Password Authentication – Less secure but can be enabled if necessary.

 

Option 1: Enable SSH Key Authentication (Recommended)

To set up SSH key authentication, generate an SSH key and copy it to the server using:

ssh-copy-id <username>@<server-ip>

(Setting up SSH keys is outside the scope of this article.)

 

Option 2: Enable SSH Password Authentication

If you prefer password authentication, modify the SSH configuration file:

sudo nano /etc/ssh/sshd_config.d/60-cloudimg-settings.conf

Find the line:

PasswordAuthentication no

Change it to:

PasswordAuthentication yes

Save and exit by pressing Ctrl + X, then Y, and Enter.

Restart the SSH service for changes to take effect:

sudo systemctl restart ssh

 


Step 4: Test SSH Access

Try logging in from your local machine:

ssh <username>@<server-ip>

If successful, SSH is now enabled!

 


Final Security Recommendations:

Disable root login via SSH by setting PermitRootLogin no in /etc/ssh/sshd_config.
Use fail2ban to block repeated failed login attempts:

sudo apt install fail2ban -y

Was this answer helpful?

« Back