Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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?
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).
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?
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.
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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.