LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-18-2011, 10:24 AM   #1
chesschi
Member
 
Registered: May 2011
Posts: 41

Rep: Reputation: 0
openssh allow/deny groups


Hi all,

I am trying to run two instances of openssh (one is sftp and one is ssh) and setup two accounts to access only one of them. i.e.

There are two configuration files (under /etc/ssh directory) with the following commands, i.e.:

sshd_config
Port 22
DenyGroups sftpAllow
AllowGroups sshAllow

sftpd_config
Port 12345
DenyGroups sshAllow
AllowGroups sftpAllow

Here are the contents of file /etc/group:
sshAllow:x:594:root
sftpAllow:x:595:userA

However, I can use ssh and sftp programs to connect port 22(12345) using root(userA) account. But I expect ssh to connect to port 22 only using root account and sftp to connect to port 12345 only using userA account.

Any idea?

Last edited by chesschi; 05-18-2011 at 11:31 AM.
 
Old 05-18-2011, 09:02 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
No idea what you're trying to say here, but a few comments:
  • Your DenyGroups directive is superfluous in this context. Remove it from both configs - for the sake of clarity.
  • If you're intending to enforce user access control (at the group level), you have the right idea.
  • If you're intending to force a shell type (e.g. bash vs. sftp-server), this is not correct.
 
Old 05-19-2011, 04:28 AM   #3
chesschi
Member
 
Registered: May 2011
Posts: 41

Original Poster
Rep: Reputation: 0
I am sorry for any misunderstanding. What I actually mean is...

The setup I mentioned above can only achieve:

1 a) Allow root account to access port 22 via ssh and sftp.
b) Disable root account to access port 9001 via ssh and sftp.
2 a) Allow userA account to access port 9001 via ssh and sftp.
b) Disable userA account to access port 22 via ssh and sftp.

But my requirement is to achieve
3) Allow root account to access port 22 via ssh only (i.e. enable ssh but disable sftp).
4) Allow userA account to access port 9001 via sftp only (i.e. enable sftp but disable ssh).

Yesterday I found out that I can enable ssh but disable sftp by commenting the line "Subsystem sftp /usr/libexec/openssh-sftp-server" in /etc/ssh/sshd_config.
However, I'm still struggling how to enable sftp but disable ssh. But one of the requirement is I cannot use other third-party software like scponly or rssh. Any other solutions apart from that?

Thanks aonmie!!!

Last edited by chesschi; 05-19-2011 at 04:29 AM.
 
Old 05-19-2011, 07:29 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Yes, if disabling sftp is required in one of the instances, that is the correct directive (Subsystem sftp...) to remove.

For forcing sftp (and disabling ssh) in the other instance, you should be able to use a Match * block -- i.e. match for some criteria like IP -- on a complete wildcard. Then you can ForceCommand internal-sftp from that block.

If any of this is unclear, check the sshd_config(5) manpages, and the ssh_config(5) manpages (PATTERNS section).
 
1 members found this post helpful.
Old 05-19-2011, 07:48 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
I'm somewhat confused, I must admit; the official openssh man-pages make
no mention of a file sftpd_config, and a google search finds your question
and a few hits for centos; where/when did the file spring into existence?



Cheers,
Tink
 
Old 05-20-2011, 02:17 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,412

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
I suspect the OP created that to clarify what it was for. I agree that using a Match block
(on username) & one cfg file makes more sense.
http://www.openbsd.org/cgi-bin/man.c...nfig&sektion=5
@OP; I'd avoid ssh to root acct; way too many people trying to break in via that path.

Last edited by chrism01; 05-20-2011 at 02:18 AM.
 
Old 05-20-2011, 04:05 AM   #7
chesschi
Member
 
Registered: May 2011
Posts: 41

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Tinkster View Post
I'm somewhat confused, I must admit; the official openssh man-pages make
no mention of a file sftpd_config, and a google search finds your question
and a few hits for centos; where/when did the file spring into existence?
Actually I copied the content of sshd_config to sftpd_config because I need two configuration files to run two instances. I'm sorry for any misunderstanding.
 
Old 05-20-2011, 04:35 AM   #8
chesschi
Member
 
Registered: May 2011
Posts: 41

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by anomie View Post
Yes, if disabling sftp is required in one of the instances, that is the correct directive (Subsystem sftp...) to remove.

For forcing sftp (and disabling ssh) in the other instance, you should be able to use a Match * block -- i.e. match for some criteria like IP -- on a complete wildcard. Then you can ForceCommand internal-sftp from that block.

If any of this is unclear, check the sshd_config(5) manpages, and the ssh_config(5) manpages (PATTERNS section).
Thanks anomie. That's working!!!

Last edited by chesschi; 05-20-2011 at 04:48 AM.
 
  


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
LXer: Why a Distro-Provided OpenSSH is Better than a Third-Party OpenSSH LXer Syndicated Linux News 0 02-02-2011 08:50 AM
dhcpd.conf question, groups and deny unknown-clients trey85stang Linux - General 1 12-29-2010 05:52 PM
never_direct deny all vs. always_direct deny all simplyrahul Linux - General 1 02-16-2005 03:42 PM
winbind: wbinfo -g only lists global groups from PDC and not local groups saradiya Linux - Networking 0 12-01-2003 03:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:33 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration