LinuxQuestions.org
Visit Jeremy's Blog.
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 06-28-2003, 07:07 AM   #1
koningshoed
Member
 
Registered: May 2002
Location: South Africa
Distribution: Gentoo
Posts: 103

Rep: Reputation: 15
Allowing sftp without giving a shell


We are running a public server where we would like to provide a more secure option than mere ftp.

Since customers can upload their own pages to the server, they have to be able to upload files, ftp is the obvious choice, but we do not want defaced websites due to password sniffing or other bugs in ftp servers etc...

So, sftp comes to mind, however, a user must have a valid shell in order to be able to use sftp, allowing him to ssh into the box (very undesirable). So, does anyone know how I can solve this? I basically need a valid shell without having a valid shell.

I have no idea how sshd actually checks this, if it is performed by actually executing something like:
${USR_SHELL} -c /usr/lib/ssh/sftpd
Then it is a simple matter writing a program that'll check that those are the arguments and then execve to that, otherwise quit.

Any help welcome.
 
Old 06-30-2003, 07:20 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,417
Blog Entries: 55

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Haven't got the URI's at hand right now, but checking Feshmeat/Googling around for "scponly" or "rssh" should give you an idea what you need to do.
 
Old 09-02-2003, 09:23 AM   #3
Freaek
LQ Newbie
 
Registered: Jul 2003
Location: Australia
Distribution: Slackware
Posts: 7

Rep: Reputation: 0
scp only homepage
http://www.sublimation.org/scponly/
 
Old 09-12-2003, 08:38 AM   #4
olagarp
LQ Newbie
 
Registered: Sep 2003
Location: Sydney Australia
Posts: 1

Rep: Reputation: 0
Set /usr/libexec/openssh/sftp-server to be the default shell in /etc/passwd

Eg. sftpuser:x:4837:4841:SFTP User:/home/sftpuser:/usr/libexec/openssh/sftp-server
 
Old 12-14-2005, 08:13 AM   #5
koyi
Member
 
Registered: Jul 2003
Location: Osaka, Japan
Distribution: Arch, Ubuntu
Posts: 421

Rep: Reputation: 31
Quote:
Originally Posted by olagarp
Set /usr/libexec/openssh/sftp-server to be the default shell in /etc/passwd

Eg. sftpuser:x:4837:4841:SFTP User:/home/sftpuser:/usr/libexec/openssh/sftp-server
Just out of curiosity. Can we just change the shell of the user to some inexistent shell so the user can't log in at all?
 
Old 12-14-2005, 08:26 AM   #6
koningshoed
Member
 
Registered: May 2002
Location: South Africa
Distribution: Gentoo
Posts: 103

Original Poster
Rep: Reputation: 15
Yes. You can set the shell to /bin/false.

As for the orriginal question, I proceeded to write sftpsh available at http://www.kroon.co.za/sftpsh.php that solved it for me. The jailprep script can probably do with some improvement but it does the job for me.

The problem with scponly was that it still allowed a little bit too much access and iirc it was extremely difficult to make it chroot.
 
Old 12-14-2005, 10:01 AM   #7
The_JinJ
Member
 
Registered: Apr 2004
Location: Scotland
Distribution: Suse, OpenWRT
Posts: 299

Rep: Reputation: 30
Have a look at http://olivier.sessink.nl/jailkit
 
Old 12-14-2005, 04:50 PM   #8
koningshoed
Member
 
Registered: May 2002
Location: South Africa
Distribution: Gentoo
Posts: 103

Original Poster
Rep: Reputation: 15
A quick look doesn't answer the obvious question: How do they actually prevent execution of other commands? Take the sftp example/howto they give, they essentially copy the required commands into the jail area _before_ the client even connects to ssh. Fair enough, fire up sftp, upload my own static executable (say my own version of bash), reconnect. Granted, not a complete installation available, but certainly some CPU available. Some memory too.

I may be wrong and they do actually do something to prevent the above "hack".

Oh, it's also possible to replace /home/jail/etc/jailkit/jk_lsh.ini. Unless of course you as the system administrator knows how to use chattr +i .

Very, very good set of tools otherwise though. As far as I can gather. Deffinately more complete than what I did.
 
Old 12-14-2005, 08:23 PM   #9
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
scponly is a quick method to prevent shell access and setting up a chroot environment.
 
  


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
Implications when giving out a shell account to execute halflife server scripts nistelrooy Linux - General 4 02-24-2006 12:00 AM
Allowing only SFTP access vanibhat Linux - Enterprise 8 06-30-2005 02:10 AM
sftp over shell script naughtymutt Linux - General 1 08-20-2004 05:56 AM
setting up/ giving out shell accounts skeletal29 Linux - Security 2 08-25-2002 02:36 AM
using sftp without having a Shell on serverside macone Linux - Security 4 08-09-2002 07:17 AM

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

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