internal-sftp for chroot: How do automatically run command at login?



I setup the new chroot jail for sftp in openssh 5.0p1. I was
wondering how I can have a command executed automatically after login
with sftp. If it were ssh, I simply could add a command to /etc/
profile, /etc/bashrc, ~/.bashrc, etc. But sftp doesn't read those
files.

My setup is:

Subsystem sftp internal-sftp
Match Group ftpuser
ChrootDirectory /opt/ftproot/%u
ForceCommand internal-sftp

So when I use logins, the user cannot write to its $HOME since that is
chown root:root due to the requirements of chrootdirectory. So I
created a directory called 'pub' in each $HOME that is writable by
that user. So instead of users having to 'cd pub' manually after each
login, I want them to be dumped automatically into pub after login.

I've tried adding 'cd pub' to /etc/ssh/sshrc and /opt/ftproot/%u/.ssh/
rc but they don't seem to be read by sftp.
.



Relevant Pages

  • Allowing sftp without remote shell
    ... There's an account on my system for which I want to allow remote sftp ... this difficult is that sftp is invoked through a regular ssh login. ... If the user tries ssh to login remotely, the login succeeds but they're now ...
    (comp.os.linux.networking)
  • Allowing sftp without remote shell
    ... There's an account on my system for which I want to allow remote sftp ... this difficult is that sftp is invoked through a regular ssh login. ... If the user tries ssh to login remotely, the login succeeds but they're now ...
    (comp.os.linux.security)
  • RE: sftp vs ftp with ssl
    ... > account with interactive shell. ... I may very well be missing something here, but isn't anonymous sftp kind ... login, then run sshd in a chroot jail, kind of the way anonymous ftp ...
    (Security-Basics)
  • Re: running sftp without login via ssh ?
    ... We want to use sftp over the internet but dont want anyone to be ... > able to get a regular login prompt via ssh. ...
    (SSH)
  • Re: Need help securing SFTP inbound (virtual root equivalent)
    ... "ron" schreef in bericht ... > Installed Openssl and ssh and have setup public key authentication. ... > Looking to automate an inbound file transfer using SFTP. ...
    (comp.unix.aix)