Is there any way to configure a user on a Linux box (Centos 5.2 in this case) so that they can use scp to retrieve files, but can't actually login to the server using SSH?

link|improve this question

I tried setting the login shell to /bin/false, but that just stops scp working altogether. – DrStalker Nov 12 '09 at 2:55
feedback

7 Answers

up vote 18 down vote accepted

rssh (http://pizzashack.org/rssh/) is designed for precisely this purpose.

Since RHEL/CentOS 5.2 doesn't include a package for rssh, you might look here to obtain an RPM: http://dag.wieers.com/rpm/packages/rssh/

link|improve this answer
that's awesome - I've been looking for something like this for a while, too – warren Nov 12 '09 at 4:44
2  
the idea behind rssh is nice, but iirc rssh wasn't exactly a miracle of security in programming terms. A simple google on 'rssh exploit' yields more results than I am comfortable with... – wzzrd Nov 12 '09 at 7:48
3  
scponly is more or less the same thing as well and apparently less exploits-prone : sublimation.org/scponly/wiki/index.php/Main_Page – François Feugeas Nov 12 '09 at 10:52
feedback

I'm a bit late to the party, however I will suggest you take a look at the ForceCommand directive of OpenSSH.

Subsystem sftp internal-sftp

Match group sftponly
         ForceCommand internal-sftp

Granted, this is SFTP and not SCP, but it reaches the same goal, more securely than with a restricted shell. Additionally, you can chroot the user if you want to.

link|improve this answer
feedback

I use MySecureShell to do this. You can configure other restrictions too.

http://mysecureshell.sourceforge.net/

Limits connections to SFTP/SCP only. No shell access.

link|improve this answer
feedback

We use a psudo shell called scponly on our secure ftp servers for users we only want to be able to scp files but not log in.

link|improve this answer
feedback

I'm way late to this but you could use ssh keys and specify the exact command allowed in their ~/.ssh/authorized_keys file e.g.

no-port-forwarding,no-pty,command="scp source target" ssh-dss ...

You may need to use ps to on the target to set the right command settings.

link|improve this answer
feedback

I'd recommend using scponly.

It is a restricted shell that allows users to do just what it sounds like, SCP files to the server, but not actually log in. Information and source code downloads for the software are available here and the pre-compiled RPM packages are available via the EPEL YUM Repositories.

Once installed, you will need to configure each user account, which you wish to restrict access to, to use the newly installed restricted shell. You can do this manually via /etc/passwd or use the following command: usermod -s /usr/bin/scponly USERNAME

link|improve this answer
feedback

Its not the most graceful solution, but you could throw something like this into the users .bashrc

if [ "$TERM"  != "dumb" ]; then
  exit
fi

I've found that SCP users get a TERM of 'dumb', and others will typically get vt100.

I imagine the user could probably scp over a new .bashrc, which makes this not the best solution, but for a quick and dirty solution, this will work

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.