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:
parent
bfe3c13470
commit
125d105403
1 changed files with 4 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue