Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a home PC and I created a reverse port forwarding to a server. Now I would like to go access to some people to the Home PC through this server. I would like to control the access of the user on this server so I added the following lines to the /etc/ssh/sshd_config

Match User restricteduser
   ChrootDirectory /home/restricteduser
   AllowAgentForwarding no
   PermitOpen localhost:3333

but when I'm trying to connect to the server

ssh restricteduser@serverIP
restricteduser@serverIP's password:

I'm getting the following error:

Write failed: Connection reset by peer
share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

The logfiles for the ssh daemon should give you specific information on what's happening here. Check /var/log/auth.log.

However, I suspect that the ChrootDirectory is what is causing problems.

When remoteuser logs in, the ssh daemon tries to chroot to /home/restricteduser and start restricteduser's shell (probably /bin/bash). Because it's chrooted, the ssh daemon will be looking for /home/restricteduser/bin/bash.

Additionally, any libraries needed by the shell need to be present in the chroot (check with ldd /bin/bash), and the same applies to any files that the shell expects to be available when started. If the ssh daemon itself needs access to files, they will need to be present too.

If restricteduser is to run any programs once logged-in, they'll need to be in the chroot too, as well as their dependent libraries/files.

This can get quite complex. If you're simply looking to provide port-forwarding, check out the answer to How to create a restricted SSH user for port forwarding?

share|improve this answer
add comment

Your Answer

 
discard

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.