0

I want to restrict my admin user to /bin directory while permitting to use bash as a shell via ssh.
This is in my sshd_config file:

Match User admin    
   ChrootDirectory /bin
   X11Forwarding no
   ForceCommand scponly
   #PermitTunnel no
   AllowTcpForwarding no

in /etc/passwd:

 admin:x:1001:100:,,,:/:/bash

when I use this command: ssh admin@192.168.1.20

this error appears:

 /bash: No such file or directory
 Connection to 192.168.200.242 closed.

if I change scponly to internal-sftp in sshd_config, all binary files exist (for example, bash) in / directory via sftp. Why I can't use /bash as a shell after changing to scponly?

How can I get this to work.

  • 1
    The authentication process and retrieval of user information such as the shell is done prior to any chrooting (basically, PAM happens before sshd). – John WH Smith Jan 4 '15 at 13:46
  • Ok, but if i change to /bin/bash, the same error occurs. how can i solve the problem? – sfallahdoost Jan 4 '15 at 14:32
  • Run ldd /bin/bash . All those shared libraries need to be available in the chrooted environment to run that command. – Mark Plotnick Jan 4 '15 at 18:31
  • That's right ...Thank you very much Mark. – sfallahdoost Jan 4 '15 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.