mirror of
https://github.com/atmoz/sftp.git
synced 2024-11-17 12:51:33 -05:00
Disable password login if password is zero
This commit is contained in:
parent
bfe3c13470
commit
125d105403
1 changed files with 4 additions and 5 deletions
|
@ -61,13 +61,12 @@ function createUser() {
|
||||||
chown root:root /home/$user
|
chown root:root /home/$user
|
||||||
chmod 755 /home/$user
|
chmod 755 /home/$user
|
||||||
|
|
||||||
if [ -z "$pass" ]; then
|
if [ -n "$pass" ]; then
|
||||||
pass="$(tr -dc A-Za-z0-9 </dev/urandom | head -c256)"
|
echo "$user:$pass" | chpasswd $chpasswdOptions
|
||||||
chpasswdOptions=""
|
else
|
||||||
|
usermod -p "*" $user # disabled password
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$user:$pass" | chpasswd $chpasswdOptions
|
|
||||||
|
|
||||||
# Add SSH keys to authorized_keys with valid permissions
|
# Add SSH keys to authorized_keys with valid permissions
|
||||||
if [ -d /home/$user/.ssh/keys ]; then
|
if [ -d /home/$user/.ssh/keys ]; then
|
||||||
cat /home/$user/.ssh/keys/* >> /home/$user/.ssh/authorized_keys
|
cat /home/$user/.ssh/keys/* >> /home/$user/.ssh/authorized_keys
|
||||||
|
|
Loading…
Reference in a new issue