LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-18-2010, 04:57 AM   #1
gajanan
LQ Newbie
 
Registered: Oct 2006
Location: bangalore
Posts: 11

Rep: Reputation: 0
SSH login restriction for root user from perticular client


Hi,
I have Linux server having the IP address 10.140.1.1.
From seven work stations (IP’s are 10.140.1.2, 10.140.1.3…….10.140.1.8) I can connect to 10.140.1.1 using SSH and root user credentials are used for login.
Now my requirement is user should be allowed to do SSH to 10.140.1.1 from 10.140.1.2 and should not log in using root credentials. Where as from other work stations (10.140.1.3, 10.140.1.4….) SSH should be possible using root credentials also.

Please let me know if you have any solution.

Thank You,
Gajanan
 
Old 08-18-2010, 06:42 AM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
add a denyusers section: below is an excerpt from the man page

Quote:
DenyUsers
This keyword can be followed by a list of user name patterns,
separated by spaces. Login is disallowed for user names that
match one of the patterns. Only user names are valid; a
numerical user ID is not recognized. By default, login is
allowed for all users. If the pattern takes the form USER@HOST
then USER and HOST are separately checked, restricting logins to
particular users from particular hosts. The allow/deny
directives are processed in the following order: DenyUsers,
AllowUsers, DenyGroups, and finally AllowGroups.
 
Old 08-18-2010, 06:56 AM   #3
rgdacosta
Member
 
Registered: Jun 2007
Location: South Africa
Distribution: Linux Mint,Fedora, openSUSE, RHEL, SLES, Scientific Linux
Posts: 71

Rep: Reputation: 25
Use the AllowUsers parameter:

AllowUsers: user1@10.140.1.1, root@10.140.1.3

AllowUsers
This keyword can be followed by a list of user name patterns,
separated by spaces. If specified, login is allowed only for
user names that match one of the patterns. Only user names are
valid; a numerical user ID is not recognized. By default, login
is allowed for all users. If the pattern takes the form
USER@HOST then USER and HOST are separately checked, restricting
logins to particular users from particular hosts. The allow/deny
directives are processed in the following order: DenyUsers,
AllowUsers, DenyGroups, and finally AllowGroups.
 
1 members found this post helpful.
Old 08-18-2010, 07:01 AM   #4
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
It is not good practice to login root user from remote.


Code:
$ sudo vi /etc/ssh/sshd_config
DenyUsers root@ipaddress
i.e
DenyUsers root@10.140.1.2
HTH

Last edited by sem007; 08-18-2010 at 07:02 AM.
 
1 members found this post helpful.
Old 08-18-2010, 11:53 AM   #5
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
From seven work stations (IP’s are 10.140.1.2, 10.140.1.3…….10.140.1.8) I can connect to 10.140.1.1 using SSH and root user credentials are used for login.
So you can have up to 7 people logging in as root? Excuse me, but that is just not a good way to go.

Quote:
Now my requirement is user should be allowed to do SSH to 10.140.1.1 from 10.140.1.2 and should not log in using root credentials. Where as from other work stations (10.140.1.3, 10.140.1.4….) SSH should be possible using root credentials also.
Instead of trying to use IP addresses to filter who does or does not have root access, how about looking at what functions need to be performed as root and using sudo to give specific people permission to do those. Maybe I'm not understanding something, but it sounds like you're trying to solve a problem the wrong way. An explanation of what you're trying to do may help.
 
Old 08-18-2010, 11:17 PM   #6
GreyCode
LQ Newbie
 
Registered: Aug 2010
Posts: 2

Rep: Reputation: 0
although i can deny that particular workstation to login directly using root, still that workstation can login with other user name and can use su . than is blocking that particular ip making any sense!!!
 
Old 08-19-2010, 05:00 AM   #7
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
Quote:
Originally Posted by GreyCode View Post
although i can deny that particular workstation to login directly using root, still that workstation can login with other user name and can use su . than is blocking that particular ip making any sense!!!
DenyUser deny userlogin

if you want to deny ssh from particular ip then you can user /etc/hosts.deny

Code:
sshd: ipaddress
or you can define iptables rule.

Last edited by sem007; 08-19-2010 at 05:03 AM. Reason: add more info
 
Old 08-20-2010, 05:24 AM   #8
gajanan
LQ Newbie
 
Registered: Oct 2006
Location: bangalore
Posts: 11

Original Poster
Rep: Reputation: 0
Thank You

Hi All,

Thanks for your valuable suggestion. It is working for me.

Regards,
Gajanan
 
Old 08-20-2010, 05:37 AM   #9
gajanan
LQ Newbie
 
Registered: Oct 2006
Location: bangalore
Posts: 11

Original Poster
Rep: Reputation: 0
Need to disable (Block) su for particular user

Hi,

Our linux server is having IP address 10.140.1.1. From the workstation 10.140.1.2 only user test is allowed to do the SSH (root credentials are restricted).
Now user test is connecting to server 10.140.1.1 from the client 10.140.1.2 and switching to root account using command su.

Please suggest me how can we block the user test to use su command once when he connect to 10.140.1.1

Thank You.

Regards,
Gajanan
 
Old 08-20-2010, 07:00 AM   #10
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Please suggest me how can we block the user test to use su command once when he connect to 10.140.1.1
As long as test has the root password (which presumably they do since they can su to root), there really isn't much you can do. Once again, I think you're looking at the problem the wrong way unless I'm not understanding something. If the user test has the need to run some commands as root, you should be using sudo to grant permission to just those commands. What you shouldn't be doing is handing out the root password and then trying to jury-rig restrictions.
 
Old 08-24-2010, 04:51 AM   #11
gajanan
LQ Newbie
 
Registered: Oct 2006
Location: bangalore
Posts: 11

Original Poster
Rep: Reputation: 0
How to block user from executing SSH command?

Hi,

Please help me to know how can we block user from executing SSH command in linux server.

Thank You,
Gajanan
 
Old 08-24-2010, 07:17 AM   #12
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
changes permissions on the ssh command such that the user in question can't run it, for example make a group called ssh
change the ownership of ssh to root:ssh with permissions 550 then only root and users in the ssh group could run ssh
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable root login, but still be able to sudo -s after logged with another user (ssh) ytd Linux - General 12 04-25-2010 11:34 AM
Passwordless login in using ssh via non root user kenpachi Linux - Newbie 3 02-15-2010 10:37 AM
SSH root login from different user Seregwethrin Linux - Software 4 05-21-2009 02:54 PM
ssh login - host restriction DoubleOTeC Linux - Networking 12 09-27-2004 08:18 AM
User restriction on SSH RKris Linux - Software 5 06-22-2003 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration