Back

Linux administration

Connecting to a remote server via SSH

Use the "ssh" utility on your local machine to connect to a remote server via SSH. This applies to Linux, macOS and Windows 10.  Use Terminal under macOS and Linux to call the ssh utility. On Microsoft Windows 10, use PowerShell.

IP address and credentials

To connect to a server, you will need its IP address and credentials for authentication (to log in). Credentials are either username and password, or username and private key.

IP address

You will find the IP addresses of a server on the server's "Details" page in the Customer Portal. Use the public IP address of your server if you're connecting via the Internet.

Credentials

For a newly provisioned dedicated server, the username is root.For a newly created cloud server with key-based authentication, the username is cloud-user.For a newly created cloud server with with password-based authentication, the username is root.

If you have not provided a public key when ordering a server, an auto-generated password will be emailed to you.

Password authentication

For password authentication, the command syntax is as follows:

ssh USER@IP

Key-based authentication

For key-based authentication, use the private key corresponding to the public key you have set up for the server.

Usually, ssh keys are stored in the ".ssh" subdirectory of the user's home directory. Assuming the key file to be "id_rsa", the command will look like this:

ssh -i ~/.ssh/id_rsa USER@IP

Note that "id_rsa" is a default file name for a private key when you generate key pair with the "ssh-keygen" utility. Your actual key may have another name. 

"Permissions too open" error

When you use a key file for the first time, you may get an error from ssh saying "Permissions for [the key file] are too open". 

Use the following command to set more restrictive file permissions for the key file under macOS and Linux:

chmod 600 ~/.ssh/id_rsa

Use the following series of commands to change file permissions in Windows PowerShell:

[String] ${stUserDomain},[String] ${stUserAccount} = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name.split("\")
icacls $home/.ssh/id_rsa /grant:r ${stUserAccount}:F
icacls $home/.ssh/id_rsa /inheritance:r

The first line extracts username of the current user. The second line grants full permissions to the current user. And the third line removes inherited permissions.

Share

Suggested Articles

  • Linux administration

    How to create a new SSH key pair

  • Linux administration

    How to protect SSH using fail2ban on Ubuntu 16.04