LinuxQuestions.org
Visit Jeremy's Blog.
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 03-24-2009, 04:34 PM   #1
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Rep: Reputation: 40
Limiting file size with sftp?


Hi group,

I need to limit the size of files transferred using sftp. Any pointers? Can't use ulimit, that limits total disk usage.
 
Old 03-24-2009, 04:45 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
Are you sure you can't use ulimit..? From manpages for bash_builtins(1):
Quote:
ulimit
...
-f The maximum size of files written by the shell and its
children
Example:
Code:
$ ulimit -f
unlimited

$ ulimit -S -f 10

$ cat /dev/zero > foo
File size limit exceeded

$ du -h foo 
16K     foo
----------

Edit: Or are you trying to say you want the restrictions to only apply for sftp (and not for a regular shell session)?

Last edited by anomie; 03-24-2009 at 04:46 PM.
 
Old 03-24-2009, 05:00 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Similar to HTTP POST uploads, as far as I know, there is nothing in the protocol itself that precedes the stream saying "look, here comes a 4GB file".
 
Old 03-25-2009, 12:49 PM   #4
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by anomie View Post
Are you sure you can't use ulimit..? From manpages for bash_builtins(1):


Example:
Code:
$ ulimit -f
unlimited

$ ulimit -S -f 10

$ cat /dev/zero > foo
File size limit exceeded

$ du -h foo 
16K     foo
----------

Edit: Or are you trying to say you want the restrictions to only apply for sftp (and not for a regular shell session)?
Yes, I want to apply the rule to each file transfer of a continuosly running sshd for a special scp-only daemon on a server.

An overview of my set up.
  • A. multiple clients that use sftp to transfer files to Hub
  • B. Hub runs scp-only daemon that accepts files from clients and then retransmit them to other clients.
  • C. other clients that accept files from Hub
I want to limit the size of the files that the Hub (B) will accept.

I will test your suggestion of usings ulimit.

Last edited by MrUmunhum; 03-25-2009 at 01:12 PM.
 
Old 03-30-2009, 04:18 PM   #5
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
ulimit does not limit sftp transfers

Quote:
Originally Posted by anomie View Post
Are you sure you can't use ulimit..? From manpages for bash_builtins(1):


Example:
Code:
$ ulimit -f
unlimited

$ ulimit -S -f 10

$ cat /dev/zero > foo
File size limit exceeded

$ du -h foo 
16K     foo
----------

Edit: Or are you trying to say you want the restrictions to only apply for sftp (and not for a regular shell session)?
I tried using ulimit but it did not work for sftp/scp file transfers. It does work for local command like 'cp', 'cat', etc.
 
Old 03-30-2009, 04:35 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
Hmm. And this doesn't seem like a candidate for quotas. I am not sure what else to suggest.
 
  


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
limit upload/download file size in SFTP bzlaskar Linux - Server 2 02-28-2009 11:25 PM
limiting some users to sftp but allowing other to ftp bmeckle Linux - General 2 04-05-2006 07:43 AM
Limiting the size of a log file ganninu Linux - General 1 09-18-2003 08:23 AM
limiting the size of each directory sophie Linux - Newbie 1 07-24-2003 11:49 AM
limiting the size of a directory chandan Linux - Newbie 1 06-30-2003 05:35 AM

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

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