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.
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 "your_email@example.com"
Using your email address allows you to easily be able to identify the SSH key.
Disable Root Logins
Disabling root logins is easy:
- Login to Web Host Manager
- Click on SSH Password Authorization Tweak under Security
- 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:
- Login to Web Host Manager
- Click on Manage root’s SSH Keys under Security Center
- Click Import Key
- Paste the Public Key in the appropriate box
- Click Manage Authorization beside the key
- 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 root@192.168.1.1 (replace with your server IP)