LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 12-12-2011, 02:14 PM   #1
td3201
Member
 
Registered: Jan 2002
Location: Omaha, NE US
Distribution: Red Hat/CentOS
Posts: 226

Rep: Reputation: 30
Question SFTP/SCP only per account


Hello,

I have a PCIDSS environment where I need to:
  1. restrict normal users to SFTP/SCP. This is easy done by setting the account to /sbin/nologin.
  2. prevent root/admin users from gaining shell access outside of certain IP block. In other words, these users have to VPN in to gain shell access.

I don't have the ability to restrict by IP address at the firewall layer unfortunately. Any ideas here?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-12-2011, 02:34 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
See AllowUsers in sshd_config(5), and the accompanying PATTERNS section in ssh_config(5). Together, they allow you to whitelist account@subnet, account@other-subnet, etc.

All else is denied by default. An alternative to this would be using pam_access(8) to whitelist an entire group@subnet. (We need to know what OS / version you're using in order to help further.)
 
2 members found this post helpful.
Old 12-12-2011, 02:36 PM   #3
td3201
Member
 
Registered: Jan 2002
Location: Omaha, NE US
Distribution: Red Hat/CentOS
Posts: 226

Original Poster
Rep: Reputation: 30
Oh fail on my part. I didn't realize I could white a user@subnet pattern. Let me chew on that. It's RHEL6.
 
Old 12-12-2011, 02:38 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,609

Rep: Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960
Quote:
Originally Posted by td3201 View Post
Hello,

I have a PCIDSS environment where I need to:
  1. restrict normal users to SFTP/SCP. This is easy done by setting the account to /sbin/nologin.
  2. prevent root/admin users from gaining shell access outside of certain IP block. In other words, these users have to VPN in to gain shell access.
I don't have the ability to restrict by IP address at the firewall layer unfortunately. Any ideas here?
If I'm understanding what you're saying correctly, you should be able to use the AllowUsers (or DenyUsers) parameters in sshd_config would be what you're after.

Set it up something like:
Code:
AllowUsers root@10.11.12.* admin1@15.16.17.19 admin2 10.11.*
DenyUsers root@192.* admin1@10.* admin2 15.*
...so root could only log in from the 10.11.12 network, and be denied if they're coming in on the 192.* network. Which, if they're VPN'ed in, I'm assuming their subnet will be identifiable, and able to be put in here. You can even allow/deny to ONE address itself.

EDIT: Dangit, I was typing when the other two replies came in.
 
1 members found this post helpful.
Old 12-12-2011, 02:42 PM   #5
td3201
Member
 
Registered: Jan 2002
Location: Omaha, NE US
Distribution: Red Hat/CentOS
Posts: 226

Original Poster
Rep: Reputation: 30
I could go RTFM but just for fun conversation, just by doing DenyUser root@192.168.* without an explicit AllowUsers root@* will root still be able to login say from 172.16.5.20?
 
Old 12-12-2011, 05:04 PM   #6
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
@td3201: I'd expect it to, but am not sure. That's one of those scenarios that is best to personally test and observe.

Again, if you find that sshd(8)'s allow/deny pattern directives are not quite meeting your needs, be sure to consider pam_access(8). It offers a little more flexibility, IMO.
 
Old 01-04-2012, 08:44 PM   #7
td3201
Member
 
Registered: Jan 2002
Location: Omaha, NE US
Distribution: Red Hat/CentOS
Posts: 226

Original Poster
Rep: Reputation: 30
I ended up going with pam_access on this for now but I may have a gap here.

1. No changes to sshd_config other than PermitRootLogin = no
2. /etc/security/access.conf looks like this (DOMAIN\foo is a Active Directory group):
+:DOMAIN\foo:10.
-:DOMAIN\foo:ALL

This works pretty well but anyone part of the domain outside of DOMAIN\foo can login. I need to be able to allow local users to login. Naturally, I can add them to a group and then put them in access.conf but I would prefer to just exclude any other domain logins such as this:
-:*\*:ALL

This doesn't work. Any other ideas?

Last edited by td3201; 01-04-2012 at 08:45 PM.
 
Old 01-04-2012, 08:58 PM   #8
td3201
Member
 
Registered: Jan 2002
Location: Omaha, NE US
Distribution: Red Hat/CentOS
Posts: 226

Original Poster
Rep: Reputation: 30
Actually, thinking about this further. I want to explicitly require that users be added to a specific group for SFTP access so I ended up with this (sftp is a local group):

+OMAIN\foo,sftp:10
-:ALL:ALL


Resolved.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
scp and sftp problem psi_mon Linux - Newbie 3 01-08-2013 07:59 AM
sftp/scp without password chuikingman Linux - Server 9 08-21-2009 06:50 AM
scp vs. sftp Holyninja Linux - Newbie 1 10-29-2007 06:28 PM
SCP/SFTP problem tpe Linux - Security 3 03-12-2005 06:58 PM
scp vs. sftp . . . zthomasz Linux - Security 2 07-08-2003 08:26 AM

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

All times are GMT -5. The time now is 06:36 PM.

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