W
W
WebDev2016-11-12 01:30:40
ubuntu
WebDev, 2016-11-12 01:30:40

Does not allow the user to ssh?

You need to let the designer on the server, that is, open access to the folder with pictures.
To do this, I created a user
sudo adduser --no-create-home designer
Set the rights to the desired folder

sudo chown designer:designer /var/www/project/public
sudo chmod 755 /var/www/project/public

Added these lines to sshd_config
Match user designer
  ChrootDirectory /var/www/project/public

Set a password for the user and restart sshd.
When I try to log in as this user, I get the error "Connection closed by remote host".
Why does it not let him in and am I setting up access to the folder correctly?
UPD: Here's what I found in the secure log
fatal: bad ownership or modes for chroot directory
UPD2: Here's what I googled about it

ChrootDirectory - This folder must be owned by root and other users must not have write access.
Otherwise, we get an error:
fatal: bad ownership or modes for chroot directory
Therefore, ChrootDirectory is made to a directory above

That is, I put /var/www/project in ChrootDirectory. Project, like var with www, is owned by root.
But now after trying to log in as designer I get an error
Could not chdir to home directory /home/designer: No such file or directory

I tried creating a user with a home directory. Now /home/designer is there, but the error is the same.
And he logs in, and then throws him out.
Last login: Sat Nov 12 00:10:31 2016 from ***
Could not chdir to home directory /home/designer: No such file or directory
/bin/bash: No such file or directory
Connection to *** closed.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2016-11-12
@saboteur_kiev Куратор тега Ubuntu

Вы же запираете пользователя в /var/www/project/public, следовательно после логина для него / это ваш /var/www/project/public.
И логично, что он не находит ни /var/www/project/public/home/designer ни /var/www/project/public/bin/bash.
Может пользователю не нужен ssh, а будет достаточно sftp? Поднимите ftp сервер и все.

Назар Мокринский, 2016-11-12
@nazarpc

1) Убедитесь, что designer имеет доступ не только к /var/www/project/public, но и ко всем родительским директориям
2) Вам не нужен chroot, с ним вам нужно будет внутрь chroot положить все необходимые бинарники вроде /bin/bash, иначе оболочка не запустится, из chroot же доступа к ним нет; просто настройте права и ограничьте оболочку нужными командами в зависимости от потребностей

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question