LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 07-20-2010, 12:40 AM   #1
davidklc
LQ Newbie
 
Registered: Jun 2010
Posts: 3

Rep: Reputation: 0
Can I allow SFTP for ANY , but SSH for some IP address


Dear All ,
Can I allow SFTP for ANY , but SSH for some IP address
 
Old 07-20-2010, 01:56 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

I don't think that is possible with just one running instance of the sshd daemon (scp, ssh and sftp are managed by this daemon). I'm sure it is possible if you set up 2 sshd daemons (both listening on a different port).

But what is the underlying problem?

If you do not want to give everybody a shell and remote execution rights ("basic" ssh) but do want to give secure upload/download access to "everyone" you might want to take a look at scponly (provide access to remote users to both read and write local files without providing any remote execution privileges).

Scponly - main page
Scponly - FAQ

Hope this helps.
 
Old 07-20-2010, 02:42 AM   #3
davidklc
LQ Newbie
 
Registered: Jun 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Hi ,
I've already config SFTP user as

sftpuser:x:2222:2000:SFTP User:/var/ftp/upload/sftpuser:/usr/libexec/openssh/sftp-server

grep 2000 /etc/group
sftponly:x:2000:

/usr/local/etc/sshd_config
Subsystem sftp internal-sftp
Match group sftponly
ChrootDirectory /var/ftp/upload/%u
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

So , the SFTP user is allow for ANY ( if firewall is allow )

But , I hope the Unix Server can let me config as SFTP for ANY , but SSH for some IP .

since TCP wrapper are only for SSHD service deamon as /etc/hosts.allow & /etc/hosts.deny
and can not config as
SFTP: ALL :allow
SSH : x.x.x.x y.y.y.y :allow

( not sure rssh can or can not )
 
Old 07-20-2010, 12:44 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
What OS / version, and - more importantly - what OpenSSH version?
 
Old 07-21-2010, 02:10 AM   #5
davidklc
LQ Newbie
 
Registered: Jun 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by anomie View Post
What OS / version, and - more importantly - what OpenSSH version?
more /etc/redhat-release
Red Hat Enterprise Linux Server release 5.5 (Tikanga)

/usr/local/sbin/sshd
OpenSSH_5.5p1, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
 
Old 07-21-2010, 12:37 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
Neat - you compiled your own current version of OpenSSH on RHEL.

I haven't tinkered with the newer versions, but sshd_config(5) seems to indicate that the Match directive will support what you want to do.

Can you not do something like..

Code:
...

# Remember to explicitly turn off all 
# authentication forms globally. The 
# needed forms should be activated in 
# the Match blocks to fine tune access
# control. 

PasswordAuthentication no

# Here we implicitly allow ssh from a couple 
# subnets 

Match address 192.168.50.0/24,192.168.51.0/24
  PasswordAuthentication yes

# Here we match all addresses for sftp; this 
# may be incorrect, and you may need to do some
# magic with a negation PATTERN

Match address *
  ChrootDirectory /var/ftp/upload/%u
  ForceCommand internal-sftp
  PasswordAuthentication yes

...
Now then, this is untested. I don't know if it's even syntactically correct. But the theory seems right to me.

Last edited by anomie; 07-21-2010 at 01:35 PM. Reason: fixed silly oversight.
 
Old 07-23-2010, 05:57 AM   #7
saifkhan123
Member
 
Registered: Apr 2009
Distribution: Red Hat/CentOS
Posts: 108

Rep: Reputation: 19
Quote:
by "anomie": Now then, this is untested. I don't know if it's even syntactically correct. But the theory seems right to me.
Well, Match directive works really fine for me, i have the same setup and its working fine. The "ForceCommand SFTP" directive prevents the user from accessing the Shell, and he can only access SFTP.
 
  


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
Chroot SSH problem: ssh working, not SFTP & SCP. NaCo Linux - Security 3 02-01-2009 02:23 AM
sftp and ssh kehkok Linux - Networking 4 09-20-2006 02:53 PM
SFTP and SSH XaViaR Linux - Security 5 07-20-2005 10:18 AM
sftp and ssh-keygen help please grayhost Linux - Newbie 2 06-26-2003 05:51 PM
ssh and sftp help Rex_chaos Linux - Networking 8 03-17-2003 08:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 01: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