IBM Cloud Docs
Why can't I log in to a virtual server through SSH?

Why can't I log in to a virtual server through SSH?

You are unable to log into the virtual server using SSH.

There are several different reasons why you can't log into the virtual server using SSH.

  • Remote logins through SSH for root are disabled.
  • Port not configured for SSH
  • Firewall is blocking SSH traffic
  • Security group is blocking SSH traffic

To attempt to resolve the login issues using SSH, try the following troubleshooting tasks:

  • Remote logins through SSH for root are disabled

    Remote logins through SSH for root might be disabled in the SSH configuration (/etc/ssh/sshd_config) of your server. Use the following instructions to enable SSH for root login.

    For security reasons, we recommended that you don't enable root for remote SSH logins. Instead, create a nonroot user for remote SSH login.

    1. Log in to KVM IPMI console for your virtual server.

    2. As root, edit the sshd_config file in /etc/ssh/sshd_config

      nano /etc/ssh/sshd_config

    3. Add a line in the Authentication section of the file that says PermitRootLogin yes. This line might exist and be commented out with a "#". In this example, remove the "#".

      #LoginGraceTime 2m

      PermitRootLogin yes

      #StrictModes yes

      #MaxAuthTries 6

      #MaxSessions 10

    4. Save the updated /etc/ssh/sshd_config file.

    5. Restart sshd service.

      • For Ubuntu or Debian Linux, run sudo systemctl restart ssh.service.
      • RHEL and CentOS Linux users, run sudo systemctl restart sshd.service.
  • Port not configured for SSH

    Check the port number that is configured for SSH in the /etc/ssh/sshd_config file. By default, SSH is configured with port 22. However, for security reasons, your administrator might change the port.

  • Firewall is blocking SSH traffic

    SSH port traffic might be blocked by your firewall. For more information, see Allowing SSH and pinging to a public subnet.

  • Security group is blocking SSH traffic

    If you use a security group to protect your virtual servers, you need to allow SSH traffic. For more information, see Creating security groups and rules.