0
0
Fork 0
mirror of https://github.com/atmoz/sftp.git synced 2024-12-22 13:14:42 -05:00

Disable password login if password is zero

This commit is contained in:
Adrian Dvergsdal 2016-09-27 23:41:58 +02:00
parent bfe3c13470
commit 125d105403

View file

@ -61,13 +61,12 @@ function createUser() {
chown root:root /home/$user
chmod 755 /home/$user
if [ -z "$pass" ]; then
pass="$(tr -dc A-Za-z0-9 </dev/urandom | head -c256)"
chpasswdOptions=""
if [ -n "$pass" ]; then
echo "$user:$pass" | chpasswd $chpasswdOptions
else
usermod -p "*" $user # disabled password
fi
echo "$user:$pass" | chpasswd $chpasswdOptions
# Add SSH keys to authorized_keys with valid permissions
if [ -d /home/$user/.ssh/keys ]; then
cat /home/$user/.ssh/keys/* >> /home/$user/.ssh/authorized_keys