This short how-to is tested on my CentOS 6.x servers:
If you run suphp or mod_ruid and offer clients ssh access on user accounts in DirectAdmin, default file permissions on files and folders is wrong when using shell and sftp, they will default be 664 and 775
# You can fix this for SFTP this way:
Edit the file /etc/ssh/sshd_config (around line number 131), it looks like this:
Change the above to be like this:
Then restart sshd. Then all files created using sftp will be 644 and all folders will be 755.
# You can fix this for SSH/Shell this way:
Edit the file /etc/skel/.bashrc and add this new line at the bottom:
What this does, is that any new user accounts you create in DirectAdmin, will have umask 022 automatically added to their file at this path: /home/USER/.bashrc
This will make it so that when using ssh/shell to create files and folders, they will get correct permissions 644 on files and 755 on folders.
It is easy to forget that this is needed for ssh/shell, because in CentOS default permissions for files and folders created by root user is correct 644 and 755, it is only for all other users using shell, that this is not correct unless fixed as described above.
If you run suphp or mod_ruid and offer clients ssh access on user accounts in DirectAdmin, default file permissions on files and folders is wrong when using shell and sftp, they will default be 664 and 775
# You can fix this for SFTP this way:
Edit the file /etc/ssh/sshd_config (around line number 131), it looks like this:
Code:
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server
Change the above to be like this:
Code:
# override default of no subsystems
Subsystem sftp /bin/sh -c 'umask 022; /usr/libexec/openssh/sftp-server'
Then restart sshd. Then all files created using sftp will be 644 and all folders will be 755.
# You can fix this for SSH/Shell this way:
Edit the file /etc/skel/.bashrc and add this new line at the bottom:
Code:
umask 022
What this does, is that any new user accounts you create in DirectAdmin, will have umask 022 automatically added to their file at this path: /home/USER/.bashrc
This will make it so that when using ssh/shell to create files and folders, they will get correct permissions 644 on files and 755 on folders.
It is easy to forget that this is needed for ssh/shell, because in CentOS default permissions for files and folders created by root user is correct 644 and 755, it is only for all other users using shell, that this is not correct unless fixed as described above.