N
N
nepster-web2014-02-06 16:24:20
System administration
nepster-web, 2014-02-06 16:24:20

How to close a user in his folder, chroot (CentOS)?

The task is this, there is a home / black_jack folder and when entering via ssh black_jack should not go beyond its user folder.
sshd configuration

Subsystem sftp internal-sftp
Match User black_jack
ChrootDirectory /home/black_jack
ForceCommand internal-sftp
AllowTCPForwarding no
X11Forwarding no

According to the manual, he gave the owner the root for the folder
chown root /home/black_jack
When you enter through Patty, the session falls out. Logs:
Feb  6 17:52:02 mj257 sshd[8480]: Received signal 15; terminating.
Feb  6 17:52:02 mj257 sshd[8653]: Server listening on 0.0.0.0 port 22.
Feb  6 17:52:02 mj257 sshd[8653]: Server listening on :: port 22.
Feb  6 17:52:33 mj257 sshd[8655]: Accepted password for black_jack from IP port 52808 ssh2
Feb  6 17:52:33 mj257 sshd[8655]: pam_unix(sshd:session): session opened for user black_jack by (uid=0)
Feb  6 17:52:33 mj257 sshd[8658]: error: /dev/pts/3: No such file or directory
Feb  6 17:52:33 mj257 sshd[8658]: error: open /dev/tty failed - could not set controlling tty: No such file or directory
Feb  6 17:52:33 mj257 sshd[8655]: pam_unix(sshd:session): session closed for user black_jack

Tell me what's the problem?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
K
kenny_opennix, 2014-02-06
@kenny_opennix

Feb  6 17:52:33 mj257 sshd[8658]: error: /dev/pts/3: No such file or directory
Feb  6 17:52:33 mj257 sshd[8658]: error: open /dev/tty failed - could not set controlling tty: No such file or directory

exist?

V
Vlad Zhivotnev, 2014-02-06
@inkvizitor68sl

A person cannot be locked in a chroot via ssh.
For example, to log in, he needs to run the file /bin/bash. And there is no such file inside the root. Like all libraries.
You need a jailkit - it's a bit different, but do your job.

A
Alexander Lebedev, 2014-02-07
@cawaleb

Read up on restricted shell, and rbash. In short, the user cannot set some variables, cannot cd, and can only run programs that have links in his home. And on the issue, show ls -la / home
and if my assumptions are correct, everything will become clear to you.

U
utz0r2, 2021-01-16
@utz0r2

Log in via sftp (for example winscp) and not putty

E
Elena, 2015-03-30
@Anilbemo

Alcohol. The most efficient way.

V
Vladislav Bushuev, 2015-03-31
@redstar

Well, perhaps alcohol is the most affordable and effective option. Since the case is metal, you don’t need to take a brush for metal, but the complete rag is the very thing!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question