How To Disable Root Logins & Replace With SSH Key

The next thing you want to do is disable root logins on your VPS so in order for someone to SSH they must have their RSA key on the server.  This is one sure way to make sure only appropriate users have access to your server.

 To see if you already have an SSH key setup (on a Mac) go to Utilities -> Terminateand type:
cd ~/.ssh

And then:

ls -l

If you see a file called id_rsa.pub then you already have a key, you just need to copy it to your clipboard:

pbcopy < id_rsa.pub

If you don’t, you can easily generate one with the following command in your Mac terminal:

ssh-keygen -t rsa -C "[email protected]"

Using your email address allows you to easily be able to identify the SSH key.

Disable Root Logins

Disabling root logins is easy:

  1. Login to Web Host Manager
  2. Click on SSH Password Authorization Tweak under Security
  3. Click the Disable Password Auth button

Import Public SSH Key

You can no longer SSH into your server using the root password, so now you need to import your key into Web Host Manager:

  1. Login to Web Host Manager
  2. Click on Manage root’s SSH Keys under Security Center
  3. Click Import Key
  4. Paste the Public Key in the appropriate box
  5. Click Manage Authorization beside the key
  6. Click Authorize

Then next time you go want to SSH into your box, you shouldn’t have to type a password.  All you need to do is define the port:

ssh -p 5622 [email protected] (replace with your server IP)
 
Was this answer helpful? 0 Users Found This Useful (0 Votes)