hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Hosting Security and Technology Tutorials : Securing SSH: protocol SSH2 and hiding the direct access of root
Reply

Hosting Security and Technology Tutorials Tutorials related to server security or the like.
Forum Jump

Securing SSH: protocol SSH2 and hiding the direct access of root

Reply Post New Thread In Hosting Security and Technology Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 06-03-2006, 06:20 AM
manuel_accu manuel_accu is offline
Disabled
 
Join Date: Jun 2006
Posts: 0

Securing SSH: protocol SSH2 and hiding the direct access of root


1) Create a new and unique root access user. Login as root using a ssh connection such as Putty. Make sure you have the latest version of Putty that supports SSH2.

Add a user named ‘admin’ or any name:

# /usr/sbin/adduser <username>
-OR-
#useradd <u_name>

#useradd admin

Verify that you have added the user

Add user to the wheel group (this is the important step in this ducument)

(The Wheel group is a user group that can gain access to root on your server by using the su command. You can add and remove users from that group as required.)

# /usr/sbin/usermod -G wheel admin

Change user permissions:

# chmod 4750 /bin/su;chown root:wheel /bin/su

(why 4(to set SUID) in chmod? It appears that the 4 sets the SUID bit, If setuid bit is set, when the file (su) is executed by a user, the process will have the same rights as the owner of the file being executed (which is root who has rwx permissions)

Further the permissions are changed so that root has read write execute permissions (47 rws, as both owner execute and SUID are set x is replaced by s) the group has execute only permissions (5 --x) while all others have no acess to the file (0 ---)

Check su command permissions

# ls -al /bin/su

The result should be: -rwsr-x--- 1 root wheel 34567 Mar 20 2005 /bin/su

Note: the file size and date may be different from the example.

Exit and relogin with the new user name admin and test out su command.
# nano -w /etc/ssh/sshd_config


2) Next we will force the use of SSH2 by changing the line "#Protocol 2, 1" to:

Protocol 2

Next, we will disable direct root login access by changing the line "#PermitRootLogin yes" to:

PermitRootLogin no

Next, we will change the ssh port to a high level port instead of '22' by changing the line "'#Port 22" to:

Port 7777

(7777 can be any other high number you desire and also available. ***Make sure this port is open if you already have a firewall installed, or you will be locked out)

Exit and save.

Restart SSH using the following command:

/etc/rc.d/init.d/sshd restart

Now exit out and restart your SSH with 7777 (or the number you entered above) as the port. Start the terminal and login with the username (admin) created above.

Note:

If you made any mistakes and you are locked out, then you have to connect using telnet and correct the problem. After the problem is corrected, you must change your password, because Telnet may have exposed your password since it transmits log in data using plain text.

3) Have the server e-mail you every time someone logs in as root:

# cd
# nano .bash_profile

And put this text at the very end:

echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | awk '{print $6}'`" support@yourdomain.com

(You can add several addresses by having a space in between. Make sure you also use an off-server email address, otherwise if the server is hacked, you won't receive any email alart.)

4) Now since everything is working well through SSH, you can disable Telnet:

# nano -w /etc/xinetd.d/telnet
Change disable = no to yes

Save and Exit

# /etc/init.d/xinetd restart

Reply With Quote


Sponsored Links
Reply

Related posts from TheWhir.com
Title Type Date Posted
Equinix Expands AWS Direct Connect Availability to Seattle Data Centers Web Hosting News 2013-05-10 11:32:28
SSHD Rootkit in the Wild Blog 2013-02-22 16:44:08
Fortune Data Centers Receives $957K Energy Rebate through PG&E Direct Access Program Web Hosting News 2012-10-04 15:18:40
AWS Direct Connect Expands to CoreSite, Equinix and Telecity Data Centers Web Hosting News 2012-01-11 10:27:21
Cloud Security Firm Dome9 Partners with WordPress, CloudFlare Web Hosting News 2011-08-10 18:28:04


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?