Below is my code to create a user account but it doesn't take a password automatically. I have to run the password command seperately to do this
What I want to do is to be able to accept the password in a script.
In linux with the "useradd' command you can give the "-p" flag to accept the password
Code:
#!/opt/csw/bin/bash
clear
# Script to add a user to this Linux system
if [ $(/usr/xpg4/bin/id -u) -eq 0 ]; then # check if user is root
read -p "Enter Group Name : " groupname # Enter group name
while [ -z $groupname ]|| egrep "^$groupname" /etc/group 1>/dev/null;
do
echo -ne "Either group exists or you entered a blank, enter groupname again: ";read -e groupname
done
echo -ne "\nPlease Enter your Group ID Number: ";read -ern3 gid
while [[ ! $gid =~ ^[0-9]+$ ]]||egrep $gid /etc/group >/dev/null;
do
echo -ne "Please re-enter your group id positive intergers only: ";read -ern3 gid
done
echo -ne "\nPlease Enter your User ID Number: ";read -ern5 uid
while [[ ! $uid =~ ^[0-9]+$ ]]||egrep $uid /etc/passwd >/dev/null;
do
echo -ne "\nPlease re-enter your uid positive intergers only: ";read -ern5 uid
done
echo -ne "\nEnter a Comment : "; read -e comment
commentstatic="Staging Account"
echo -ne "\nEnter your Staging FTP directory location.......... "; read -e ftpdir
while [ ! -d "$ftpdir" ];
do
echo -ne "\n$ftpdir Directory Not Found! Please re-enter: "; read ftpdir
done
username="s"$groupname #getting username from groupname
/opt/csw/bin/gsed -e '/ftp/s/$/,'"$username"'/' -i /etc/group # this line is to add user to ftp group.........."
echo -e "\nAdding group $groupname......." #Adding group to group file
groupadd -g $gid $groupname
echo -e "Finished adding $groupname to group file......."
echo -e "\nAdding user to system.........."
/usr/sbin/useradd -u $uid -g $groupname -c "$comment $commentstatic" -d /forms1/prodenv/$groupname $username
sleep 2
echo -e "\nFinished adding $username to password file......." #Adding user to password file
echo -e "\nLinking source directory to home directory......."
cd /forms1/prodenv
ln -s /stage001/stageenv/$username $groupname
echo -e "\nDone linking home directory......"
echo -e "\nLinking source storage directory to home storage directory......."
cd /forms/
ln -s /stage001/stageenvsa/${username}sa ${groupname}sa
echo -e "\nDone linking storage directory......"
echo -e "\nSetting security on directories................"
chown $username:$groupname /stage001/stageenv/$username
chown $username:$groupname /stage001/stageenvsa/${username}sa
chmod 775 /stage001/stageenv/$username
chmod 775 /stage001/stageenvsa/${username}sa
echo -e "\nFinished setting security on directories................"
echo -e "\nSetting up the FTP directory................"
cd /ftp
ln -s $ftpdir $username
echo -e "\nSetting security on FTP directory................"
chown $username:ftp $ftpdir
chmod 775 $ftpdir
echo -e "\nFinished setting security on FTP directory................"
echo -e "\nSetting up services file................"
serviceadd=`tail -1 /etc/services | awk '{print $2}'| cut -c 1-5`
let serviceadd++
echo -e "$username""trck" "\t$serviceadd/tcp" "\t\t# $comment Staging Svc Account" >> /etc/services
echo -e "Finished setting up services file................"
echo ""
echo ""
fi
I have a local account for a unix server. The idle timeout for the account is around 10 mins. I have to login to the server multiple times during the day. Is there a way to increase the idle timeout or may be a script that I can run on background so it is not idle. Something like echo date every 9... (3 Replies)
I am trying to create a shell script that will:
check if a specific user already exists
if not, create a specific group and create the user in that group
assign a password to that user, where the password is passed in as a parameter to the script
The problem that I need help with is 3 on... (4 Replies)
HI I 'm new shall script and unix. I want to create script for change password root by ssh-keygen command . I have 50 servers and I want ot login ot the servers via ssh by type ones password and can login every machines.The script ssh-keygen must ot generate key every weekly than it send new... (2 Replies)
Hello,
To learn ZFS, i try to create pool .
and for that i want create 10 files with 512MB (because i dont have multiple disks and multiple controllers)
ADMIT THAT THIS IS TEN HIGH-PERFORMANCE HARD DRIVES
To get this 10 files,all of them have the same size : 512MB,
I do these... (0 Replies)
Hi,
I am using Solaris 10 OS and Bash shell.Is there any way can we automate User creation and setting passwords through a script or any freeware tool.
Advance thanks for your response. (1 Reply)
Below is my code to create a user account but it doesn't take a password automatically. I have to run the password command seperately to do this
What I want to do is to be able to accept the password in a script.
In linux with the "useradd' command you can give the "-p" flag to accept the... (1 Reply)
:eek:Below is my code to create a user account but it doesn't take a password automatically. I have to run the password command seperately to do this
What I want to do is to be able to accept the password in a script.
In linux with the "useradd' command you can give the "-p" flag to accept the... (1 Reply)
Hi
I am checking status of sftp in Health check script, sftp command is used to connect the server with secure RSA key, which is successfully get connected most of the time but in some case if RSA key ask for password then I need to exit sftp command after few second and continue to run... (1 Reply)
Hi
I have a root script which is setting up user and his dirs and so on. After I create user and set up all the necessary I have to manually set user password. I try all possible ways what google find me and nothing works for me. If maybe one of you have a solution for my problem it will be... (1 Reply)