Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/
The directory is mounted with mount -o bind /var/www/websites/site1/ /vhosts/

The sshd_config is:

Match user stefanos
   ChrootDirectory /vhosts/
   ForceCommand internal-sftp

The log is:

Jun 23 15:42:52 hostname sshd[32447]: Accepted password for stefanos from 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 ??

share|improve this question
up vote 2 down vote accepted

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/

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.

share|improve this answer
Thanks for the answer! didn't know it worked this way.. I set the home to / :) – Stefanos Kalantzis Jun 23 '11 at 13:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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