I am running Amazon Linux AMI (Red Hat derivative), and am creating a new SFTP server using OpenSSH. I would like for the SFTP user to be restricted to a directory, and to be able to write to the initial directory that is shown by their SFTP client.
I am using ChrootDirectory to chroot the user to /home/customers/srgcompany
. That means that this directory has to be owned by root and only writable by root. The user's passwd entry looks like fflintstone:x:508:515:Fred Flintstone:/home/fflintstone:/sbin/nologin
. I have placed the user's public key in /home/fflintstone/.ssh/authorized_keys
. I've created a folder that the user's group (srgcompany
) has read/write/execute/sgid permission on at /home/customers/srgcompany/fileshere
. I've configured OpenSSH's SFTP with Subsystem sftp internal-sftp -u 0007 -l INFO
.
So right now, when the user uses an SFTP client to connect, the directory that gets shown (and is returned by the pwd command) cannot be written to. The user can cd to the fileshere folder, and write there. Is there any way to make that fileshere folder be the initial remote working directory as soon as the user SFTP's in, like in the example below? Or, can I make the chrooted folder be writeable?
What I want:
$ sftp sftpserver.sssprockets.com
Connected to sftpserver.sssprockets.com.
sftp> pwd
Remote working directory: /fileshere
Any help is much appreciated.