Last active
June 16, 2019 12:38
-
-
Save gustavoapolinario/d542aaa6ec5b5b2b7eae7301011cf7b2 to your computer and use it in GitHub Desktop.
This script will create a new stpf user with non interactive mode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
set newUser [lindex $argv 0] | |
set newPassword [lindex $argv 1] | |
spawn passwd $newUser | |
expect "New password:" | |
send "$newPassword\r" | |
expect "Retype new password:" | |
send "$newPassword\r" | |
expect "passwd: all authentication tokens updated successfully." | |
send "exit\r" | |
expect eof |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# sudo ./create-user-ftp.sh NEW_USER | |
if [ "$#" -eq 0 ]; then | |
me=`basename "$0"` | |
echo "./$me [USERNAME]" >&2 | |
exit 1 | |
fi | |
if [ "$EUID" -ne 0 ] | |
then echo "Please run as root" | |
exit | |
fi | |
newUser=$1 | |
echo "new user: $newUser" | |
newPassword=$(</dev/urandom tr -dc '12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB' | head -c8; echo "") | |
echo "new password: $newPassword" | |
#sftp-user create $newUser | |
/home/ec2-user/create-user-ftp2.sh $newUser $newPassword | |
#sudo passwd $newUser | |
/home/ec2-user/change-password.sh $newUser $newPassword | |
usermod -G sftp $newUser | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
set newUser [lindex $argv 0] | |
set newPassword [lindex $argv 1] | |
spawn sftp-user create $newUser | |
expect "Enter password:" | |
send "$newPassword\r" | |
send "exit\r" | |
expect eof | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment