Logging In as Root via SSH

From PrgmrWiki


Introduction

This page is for users who wish to control their service by the command line, as the root user. If you wish to use the serial console, see here.

Note that root access is both powerful and potentially risky. Be sure that you know what you're doing as root, since a mistake in a command can have serious consequences for your data or your operating system.

Setting up OpenSSH and Making an SSH Key Pair

OpenSSH is a common open-source SSH client application. If you don't have an SSH key already then see Making an ssh key for more information on installing OpenSSH and generating a key pair.

Setting the Public SSH Key on your VPS

Once you've made your SSH key pair, you will need to log in to your account through the prgmr.com website to install the public key on your VPS. You will also need to locate your SSH public key on your computer.

  • On Windows the default location is C:\Users\[username]\.ssh
  • On Linux and MacOS the default is ~/.ssh/

If you did not use these defaults when you generated your key pair, then navigate to the directory that you chose.

The private key will be named [keyname], as set when you generated the key pair. The public key will be be named [keyname].pub. So for example "id_rsa" and "id_rsa.pub".

  1. Open your public SSH key in a text editor.
  2. In your browser, navigate to www.prgmr.com
  3. In the upper right corner of the page, click "Log In," and enter your credentials.
  4. In the block labeled "Services," find the name of the VPS that you want to work with.
  5. Click the "Manage" link at the far right end of the row to open your account page.
  6. In your account page, click "SSH Keys" on the left.
  7. In the SSH keys text box, copy paste your SSH public key.
  8. Log out of your account and close the page.

NOTE: This procedure can only add a new SSH key to your VPS. It does not remove or overwrite the old one, if there is any.

Logging in as root

  1. Open a command prompt for your system.
    • For Linux, open a terminal emulator by your favorite method, according to your distribution.
    • For Windows, press the Windows key and type cmd in the search box. Select "Command Prompt" from the search results.
    • For MacOS, open the Finder from the Dock. Select "Other," then select "Terminal."
  2. Navigate to the folder that you used to store your SSH key. See the section above.
  3. Log in with the following commands and your SSH pass phrase. Your output may differ slightly from this.
    • [keyname] is the name of your SSH private key.
    • [name] is the label of your VPS.

ssh -i [keyname] root@[name].xen.prgmr.com
The authenticity of host '[name].xen.prgmr.com ([IP Address])' can't be established.
ECDSA key fingerprint is SHA256:HS8ds5KQojGcHtQpnWk1P0ouNhnBtadvsis7eyox6dE.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[name].xen.prgmr.com' (ECDSA) to the list of known hosts.
Enter passphrase for key 'id_ed25519':
Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-26-generic x86_64)

* Documentation:  https://help.ubuntu.com
* Management:     https://landscape.canonical.com
* Support:        https://ubuntu.com/advantage

Last login: Sun Sep 13 22:40:27 2020 from 111.111.111.111
root@[name]:~#

Logging out

When you are ready to log out of your machine, enter exit at any command prompt.