IT Mehfil  

Go Back   IT Mehfil > Hidden Boards > Web Hosting Forum - Web Hosting - Web Host - Hosting - Managed Hosting - Shared Hosting > VPS Forum

Notices

VPS Forum Virtual Private Server Talk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 24-05-09, 11:44 AM   #1 (permalink)
Junior Member
 
Join Date: May 2009
Posts: 3
Credits: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
muzi09 is on a distinguished road
Default Securing your new VPS

Hey Everybody,

Finding out your VPS has been hacked is like walking out to your car, and seeing the gaping hole where your stereo used to be. It hurts, bad.

However there are plenty of steps you can take as a VPS owner to secure your setup. Most of these are fairly basic and can halt the majority of hacking attempts.

If you need help setting up or configuring anything listed below, don't hesitate to contact support. Who knows, you could get lucky and get me for your tech!

1) Securing SSH
SSH presents a unique problem. It is necessary for system administrators to manage their servers, and because of that it raises security vulnerabilities.

For those of you who use cPanel / Plesk or Webmin-Usermin, you may not use SSH everyday, or at all. It is easy to forget about it.

1.1 don't login (or allow logins) to ssh as 'root'
The user root is way, way to powerful to be allowed direct remote access. This does not mean you need to disallow root functions over ssh. In this setup another user is first used to login to ssh, and then the sudo command is used to allow root only operations. (Don’t worry, it’s not complicated... really it’s not

First ssh in to your VPS (if you have to use root this time, so be it)
at the prompt type the command

Code:
nano -w /etc/ssh/sshd_config
this will open the Nano text editor and allow you to edit the ssh configuration

find the line

Code:
# PermitRootLogin yes
and change it to

Code:
PermitRootLogin no
hit cntrl + x to exit Nano, then hit y and then enter to save the file

Now, we need to make a user to login to SSH when root level functions need to be performed.

when you are at the command line in ssh type the following command

Code:
useradd NewUserName -g wheel
this will create a new user in the wheel group (change NewUserName to whatever you want this user to be called)

Next run

Code:
passwd NewUserName
and enter the new password for the user you just created

Please Please Please use strong passwords, they are your first line of defense against hackers. Setting your password to doggie, is about the same as locking your front door with a q-tip and some scotch tape. Google "complex passwords" for some help picking one

Now we need to edit the suddoers file. This file determines who is allowed to use the sudo command, and that is what will allow you to act like root, without actually using the root account.

Since we added the new user to the wheel group, all we need to do in here is allow the wheel group to sudo. This is already in the file so all we need to do is remove the comment in front of it. Here is how

Code:
nano -w /etc/sudoers
Find the line

HTML Code:
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

and remove the # like so

Code:
# Uncomment to allow people in group wheel to run all commands
%wheel ALL=(ALL) ALL

again, hit cntrl -x, then y and then enter to exit and save the file

Now, all you need to do is run the following command to restart ssh services and you done (you may get booted out of ssh after you run this command)

Code:
service sshd restart
All set, you have no disallowed the root account to login through ssh.

To login to ssh to perform root functions, use the following steps.

SSH to your server using the username and password you created above, not root.

Next type the following command

Code:
sudo su -
This will bounce you up to root for the entire time you are logged in. Alternatively you can use sudo in front of any command to run just that command as root
For ex.

Code:
sudo nano -w somefile.txt
would open somefile.txt as the root user.

1.2 Changing the SSH port

The standard port for SSH is 22, and hackers are well aware of this fact. Changing the ssh port is a great way to avoid some common brute force hacking attempts and the like.

First ssh into your VPS (using the new account and password from above and then sudoing up to root)

Edit the ssh config file

Code:
nano -w /etc/ssh/sshd_config
Now, find the line labled

Code:
# Port 22
and change it to

Code:
Port zxy
where zxy is any 4 digit number you wish, (note this number)

hit cntrl + x to exit Nano, then hit y and then enter to save the file

Now, you need to open up this new port in your VPSs firewall. If you dont know how to do this already, dont attempt it before consulting support.
Simply open a support ticket, and we will have this port opened for you in half a jif, just make sure to include the port number you have set in the ticket.

Now, restart sshd with the folowing command, and your all set. Remember to change the ssh port in whatever client ssh program you use to connect to your VPS.

Code:
service sshd restart

muzi09 is offline   Reply With Quote
Old 02-07-09, 10:46 PM   #2 (permalink)
Junior Member
 
Join Date: Jun 2009
Posts: 17
Credits: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
huda is on a distinguished road
Default Re: Securing your new VPS

this is very very very useful information
huda is offline   Reply With Quote
Old 04-07-09, 10:03 PM   #3 (permalink)
Administrator
 
Join Date: Aug 2008
Location: karachi
Posts: 751
Credits: 11,810
Thanks: 7
Thanked 38 Times in 35 Posts
My Mood:
Rep Power: 10
balli87 is on a distinguished road
Default Re: Securing your new VPS

Quote:
Originally Posted by huda View Post
this is very very very useful information
thanks alot huda.
balli87 is offline   Reply With Quote
Advertisement
 
Advertisement
Advertisement Sponsored links

Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Securing Your Business with Cisco ASA and PIX Firewalls syndicate Applications Download 0 06-11-08 11:46 AM
Securing Cisco Networking Devices (SND) v2.73 pass4sure dumps syndicate Applications Download 0 13-09-08 10:00 AM


All times are GMT +5. The time now is 08:13 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
Ad Management by RedTyger
     
free counters

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160