Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
06-28-2003, 07:07 AM
|
#1
|
Member
Registered: May 2002
Location: South Africa
Distribution: Gentoo
Posts: 103
Rep:
|
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.
|
|
|
06-30-2003, 07:20 AM
|
#2
|
Moderator
Registered: May 2001
Posts: 29,417
|
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.
|
|
|
09-02-2003, 09:23 AM
|
#3
|
LQ Newbie
Registered: Jul 2003
Location: Australia
Distribution: Slackware
Posts: 7
Rep:
|
|
|
|
09-12-2003, 08:38 AM
|
#4
|
LQ Newbie
Registered: Sep 2003
Location: Sydney Australia
Posts: 1
Rep:
|
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
|
|
|
12-14-2005, 08:13 AM
|
#5
|
Member
Registered: Jul 2003
Location: Osaka, Japan
Distribution: Arch, Ubuntu
Posts: 421
Rep:
|
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?
|
|
|
12-14-2005, 08:26 AM
|
#6
|
Member
Registered: May 2002
Location: South Africa
Distribution: Gentoo
Posts: 103
Original Poster
Rep:
|
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.
|
|
|
12-14-2005, 10:01 AM
|
#7
|
Member
Registered: Apr 2004
Location: Scotland
Distribution: Suse, OpenWRT
Posts: 299
Rep:
|
|
|
|
12-14-2005, 04:50 PM
|
#8
|
Member
Registered: May 2002
Location: South Africa
Distribution: Gentoo
Posts: 103
Original Poster
Rep:
|
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.
|
|
|
12-14-2005, 08:23 PM
|
#9
|
Senior Member
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552
Rep:
|
scponly is a quick method to prevent shell access and setting up a chroot environment.
|
|
|
All times are GMT -5. The time now is 04:10 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|