Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm one of those guys who climbs up the ladder to the high dive and jumps off, then realizes he doesn't know how to swim.

So I have a VPS, and I have no idea how to administer it. I understand one of the first things to do is secure it, and the first concrete step in that direction I've found so far is in moshen's comment:

Also, you should secure your SSH access as soon as possible. I recommend changing the default port, using key-based authentication and disabling password authentication and root logins (basically create a standard user account for you to log in with)

So far, all I know how to do is use my VPS provider's web interface to open a console with root access. So how do I follow moshen's advice?

share|improve this question
You can find several tutorials on this with a quick Google search. Here's one such tutorial. – nojak Aug 24 '12 at 7:33
Well I was directed here from stack overflow. I'll go over to one of those. Eventually I'll get bumped to the correct place, I guess. – brentonstrine Aug 24 '12 at 7:38
Eventually the people at SO will learn there's more than two Stack Exchange sites. :) – Michael Hampton Aug 24 '12 at 7:39
The people on SO don't really don't seem to care about what does and doesn't belong here. They just send over anything they don't like, whether it's appropriate or not. This site is for IT professionals and as a professional we expect everyone to show due diligence before posting. – John Gardeniers Aug 24 '12 at 9:34

To secure your ssh you should do the next:

1) Make sure that you have an user with sudo access and public key, to do so follow the next steps:
a) Create the user by issuing:

useradd sudo_user

b) Login as this user and create a public/private key set, after which set the authorized_keys:

su - sudo_user
ssh-keygen -t rsa
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
cat ~/.ssh/ > ~/.ssh/authorized_keys

c) Get your private key from /home/sudo_user/.ssh/id_rsa that you will further use to login to the server:

cat /home/sudo_user/.ssh/id_rsa

d) Set sudo access for your user:

echo "sudo_user  ALL=(ALL)       NOPASSWD: ALL" >> /etc/sudoers

2) Edit your /etc/ssh/sshd_config config and make the next changes:
a) Disable root access by making sure the next lines says:

PermitRootLogin no

b) Disable password authentication by setting:

PasswordAuthentication no


PubkeyAuthentication yes

c) Change the port for ssh, make sure that the new port is open in the firewall first:

Port 12345

You can change it though to anything you like. d) Reload ssh by issuing:

service sshd reload


service ssh reload
share|improve this answer
+1 great answer! – dunxd Aug 24 '12 at 14:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.