Password change logic for remote machine using shell and expect
Day before yesterday,I got the success creating a shell script using expect tool and now it is running successfully on the server.
Now I want to make some changes in paswwordchanger.sh as you can see it can handle only one user i.e dbaguest and not other user.So I am thinking the logic how I can implement.
Corrent script will work in following order:
One ssh.csv file will be generated using below query which needs to be called inside passwordchanger.sh
(1) It will accept newpassword for dbaguest and it will be stored in a variable i.e paswd.
(2) It will generate a file ssh.csv using boatid where authentication for the user is true.
(3) It will read each line in ssh.csv file and will connect to the host and will change the password with new password what we are passing in step1.
(4) If it fails then it will write it into a log file with ipaddress.
Here I want to make it for other user as well suppose oracle user is there for which I have access but directly I can not login to the server using spawn ssh oracle@ipaddr.
It must login first dbaguest and then su – oracle or other user and then change the password.
For above task I have to play with username variable in passwordchanger.sh with if condition or using case statement.
please suggest me correct line where I can modify and what can be modified.
I appreciate your help.Its a bit urgent.
I am listing my script below which is running successfully:--
Moderator's Comments:
Removed excessive formatting (is it really necessary to format each line on it's own?), added code tags, added meaningful title. Due to multiple cases of this, this user has been temporarily set to "Read Only"
Last edited by manish_1678; 10-13-2010 at 03:08 AM..
Ladies & Gents,
Can one of you gurus please show me a very simple "expect" script to change the password in Solaris in a script, please? Nothing fancy, no error checking, no nothing. Just to change the password of a new user, it's all.
Many thanks in advance. U guys have honestly earned my... (1 Reply)
I want to execute a shell script(set of commands) on remote machine and that script takes input from text file(local machine). Please refer below:
ssh user@hostname 'bash -s'< ./test.sh file.txt
But i got the error file.txt doesn't exist.
Can anyone help me on this.
Content of test.sh:
... (2 Replies)
Hi All,
We have 2 servers A and B.
B is having a sctipt called b.sh in path /home/dev/scripts.
Now my requirement is i want to execute b.sh from server A.
Kindly help me. (3 Replies)
Not able to execute the file in remote host using except utility
I am automating the SFTP keys setp process:
So i created the expect script for controlling the output of shell
below is my main code:
Code:
#!/usr/bin/expect
set fd
set password
close $fd
set df
set app
close $df... (1 Reply)
Hi all,
Really hope someone can help me, i have been trying lots of things and just cant seem to nail it - and for something that seems straight forward....
Anyway, scenario is I need to log onto a second machine (remote server) from main workstation. Once logged in I need to run a batch... (2 Replies)
HI,
I need to write a script ..
when I run this script , will directly goto that remote machine without asking password..
Once it is entered, I needs to transfer some of the log files...
how can I proceed ? (7 Replies)
Hi Friends.
I am new to scripting now i want to change the root password using the script with standard password.
which is the easy scripting to learn for the beginner, Thanks in advance. (2 Replies)
Hi,
I need to login into remote server and execute a shell script over there.
As of now i am making use of ssh command
ssh primUser@135.254.242.2 sh /poll.sh
I am logging in as primUser but unless i change the user to root the script execution on the remote machine is not possible.
... (5 Replies)
I would like to change permissions recursively on a remote folder.
Seems like sftp has a limitation, I am only able to change permission on a individual file..
sftp > chmod 777 /usr/local/apache/docs/test.txt
It would be great if someone has more knowledge on how this is doable recursively? (1 Reply)
Hi,
Does anybody know how to change the password on multiple servers with a script. I have 300 Sun boxes and the password expiry is set to 30 days. Im in a process to build a script using expect. Need a help from an expert who has already done it.
Regards,
Vinod (1 Reply)