2

I have a configuration where specific users can log-in only in sftp and not ssh.
Also the users are jailed in specific directories.

Lets say the user name is stefanos and his rooted directory is /vhosts/wild.domain.com/
The directory is mounted with mount -o bind /var/www/websites/site1/ /vhosts/wild.domain.com/

The sshd_config is:

Match user stefanos
   ChrootDirectory /vhosts/wild.domain.com/
   ForceCommand internal-sftp

The log is:

Jun 23 15:42:52 hostname sshd[32447]: Accepted password for stefanos from 11.22.33.44 port 64759 ssh2
Jun 23 15:42:52 hostname sshd[32447]: pam_unix(sshd:session): session opened for user stefanos by (uid=0)
Jun 23 15:42:52 hostname sshd[32572]: subsystem request for sftp
Jun 23 15:43:07 hostname sshd[32447]: pam_unix(sshd:session): session closed for user stefanos

The problem is (thrown by WinSCP):

Cannot get real path for '/var/www/websites/site1'.
No such file or directory.
Error code: 2
Error message from server: No such file
Request code: 16

The strange thing is that when I click OK to the error message, it then logins correctly with all directories in their place.. What am I missing here ??

1 Answer 1

2

Chroot sets / to be that directory. The users home directory is apparently set to /var/www/websites/site1 so when WinSCP logs in, it tries to start in the user's home directory which on the actual system would be /vhosts/wild.domain.com/var/www/websites/site1

Presuming this stefanos user only accesses the system through sftp, it would be safe to set the home directory to /. Otherwise, I think the message should probably go away if you set a default Remote Directory in WinSCP's "Directories" tab.

1
  • Thanks for the answer! didn't know it worked this way.. I set the home to / :) Jun 23, 2011 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .