How to: Restrict Users to SCP and SFTP and Block SSH Shell Access with rssh

FTP is insecure protocol, but file-transfer is required all time. You can use OpenSSH Server to transfer file using SCP and SFTP (secure ftp) without setting up an FTP server. However, this feature also grants ssh shell access to a user. Basically OpenSSH requires a valid shell. Here is how sftp works:

SCP/SFTP -> SSHD -> Call sftpd subsystem -> Requires a shell -> User can login to server and run other commands.

In this article series we will help you provide secure restricted file-transfer services to your users without resorting to FTP. It also covers chroot jail setup instructions to lock down users to their own home directories (allow users to transfer files but not browse the entire Linux / UNIX file system of the server) as well as per user configurations.

rssh ~ a restricted shell

rssh is a restricted shell for use with OpenSSH, allowing only scp and/or sftp. It now also includes support for rdist, rsync, and cvs. For example, if you have a server which you only want to allow users to copy files off of via scp, without providing shell access, you can use rssh to do that.

Supported operations using rssh

Restricted shell only allows following operations only:

  • scp - Secure file copy
  • sftp - Secure FTP
  • cvs - Concurrent Versions System ~ you can easily retrieve old versions to see exactly which change caused the bug
  • rsync - Backup and sync file system
  • rdist - Backup / RDist program maintains identical copies of files on multiple hosts.

Install rssh

CentOS / Fedora / RHEL Linux rssh installation

Visit Dag's repo to grab rssh package
# cd /tmp
# wget http://dag.wieers.com/rpm/packages/rssh/rssh-2.3.2-1.2.el5.rf.i386.rpm
# rpm -ivh rssh-2.3.2-1.2.el5.rf.i386.rpm

Debian / Ubuntu Linux rssh installation

Use apt-get command:
$ sudo apt-get install rssh

FreeBSD installation

# cd /usr/ports/shells/rssh
# make install clean

Make sure you build binary with rsync support.

rssh configuration file

  • Default configuration file is located at /etc/rssh.conf (FreeBSD - /usr/local/etc/rssh.conf)
  • Default rssh binary location /usr/bin/rssh (FreeBSD - /usr/local/bin/rssh)
  • Default port none - ( openssh 22 port used - rssh is shell with security features)

Continue reading rest of the rssh a restricted shell series.

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 9 comments… read them below or add one }

1 john 01.02.08 at 8:45 pm

How about a suse procedure?

2 vivek 01.02.08 at 8:58 pm

john,

The procedure is same for Suse Linux, just download and install rpm file

3 J.P. Pasnak 01.02.08 at 9:52 pm

As a note, rssh is available in Mandriva Contribs (for 2008 and Cooker at least). So ‘urpmi rssh’ should work fine.

4 Christoph Langner 01.04.08 at 12:19 am

The developer of rssh quit the development of rssh two years ago. I wouldn’t recommend to use rssh since security issues won’t be fixed. Better use scponly…

5 FreeMa 01.22.08 at 3:22 pm

For those using Ubuntu (tested on Gutsy 7.10), I suggest that you follow these instructions:

http://geekzine.org/2007/09/28/easy-sftp-and-chroot-sftp-with-scponly/

FreeMa

6 khurram 06.25.08 at 4:53 pm

Hi Vivic,

Thank a lot, I a have installed the SFTP server using the above procedure. Now i want that users can login using there public and private key pairs instead of passwords.Is it possible? can any one help me please. Thanks.

7 Webagentur 11.05.08 at 3:28 pm

Why install this rssh?

8 Girish 04.29.09 at 3:59 pm

This is awesome! Thank you for posting this.

Girish

9 speller 04.30.09 at 12:32 am

Not sure what to download for Suse Enterprise?

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , , , , , , , , , , , , ,

Previous post: Best Linux / UNIX Posts of 2007: Part ~ II

Next post: Best Linux / UNIX Posts of 2007: Part ~ III