Answer the question
In order to leave comments, you need to log in
How to open access to a user to a specific folder via sftp?
there is a folder
/var/www/site
#Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp
Match User manager_user
ChrootDirectory /var/www/site/data/www/site.ru/upload/images_person
ForceCommand internal-sftp
systemctl stop httpd
systemctl start httpd
Feb 5 17:15:47 site sshd[17844]: Accepted password for manager_user from ip port 30517 ssh2
Feb 5 17:15:47 site sshd[17844]: pam_unix(sshd:session): session opened for user manager_user by (uid=0)
Feb 5 17:15:47 site sshd[17844]: fatal: bad ownership or modes for chroot directory component "/var/www/site/" [postauth]
Answer the question
In order to leave comments, you need to log in
Here is a little info
. Create a new user:
-m - indicates the need to create the user's home directory in the /home directory;
-s - Specifies the user's shell - /sbin/nologin
Prevents the user from using the shell.
crazyadmin - username
Set a password for the created user:
If something went wrong, you can always delete the user with the userdel username command, for example:
And create a chroot folder for the new user, its purpose will be described below.
Setting up the SSH server
Now we go to the SSH config - We are /etc/ssh/sshd_config
looking for the following line:
and change to
Now we go to the very end of the config, and add there:
Match User crazyadmin
X11Forwarding no
AllowTcpForwarding no
AllowAgentForwarding no
PermitTunnel no
ForceCommand internal-sftp
ChrootDirectory %h/chroot
/home
and look for the folder of the newly created user, and in it the chroot folder. Set it to be owned by the root user:/var/www/sysadmin.ru
. /home/crazyadmin
Create a folder called sysadmin.ru in the user's home directory . /var/www/sysadmin.ru
:chmod 777 /var/www/sysadmin.ru
find /var/www/sysadmin.ru -type f -exec chmod 664 {} +
find /var/www/sysadmin.ru -type d -exec chmod 777 {} +
fatal: bad ownership or modes for chroot directory component
- as mentioned above, this error appears when the owner of the ChrootDirectory is not the root user, and the rights are not equal to 755.No supported authentication methods available (server sent public key)
- the server is configured for authorization by key. If you need password authorization, then in the config /etc/ssh/sshd_config
you need to change the value of the PasswordAuthentication variable from no to yes, and then restart the server with the commandservice ssh restart.
There is also a good instruction here: Adding a new SFTP user to BitrixVM
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question