Hi there. I've been forced by circumstance to write an expect script to handle password updates on a number of servers. There's a mix of Solaris 8, 9, 10, RedHat and Ubuntu. There's no chance the client will allow us to hook them up to a directory, so we have to make do.
This script is mostly intended for myself and my colleagues to update our own passwords, but I've built in the ability for it to update a user's passwords. I've also elected to use ssh $server sudo passwd to get around the not-standardised password policies. It has a wrapper script written in bash, so in the near future I may enforce a password policy there.
I've found some unexpected behaviour though. As part of error-handling, I'm trying to cater for instances where the script logs in to a server as the sysadmin, but finds that their password is expired. Here's the relevant bit of the script, and hopefully the comments will help you follow the logic:
Here's the behaviour (sanitised and using QWERTYuiop12345 as an example password)
And here's the debug:
So you can see that -re "$whoami@$server's \[pP\]assword:" is found, the password is sent, and the script moves on. It then finds (current) UNIX password: and dutifully sends the password, however that password is printed out to the console (echoing off the remote ssh process?) and we get an Authentication token manipulation error.
The if/else works fine. I've also commented it entirely out and just had
with the same behaviour. Could it be the buffer?
Apart from this one niggle, the rest of the script works exactly as desired.
Newbie here. My goal is to have the expect script log into the Ubuntu 18.04 server and run two commands (lsb_release -a and ip addr) and eventually pipe the output/results to a file. For now, I would be happy to get this one command or two to run successfully. How to fix this?
#!/usr/bin/expect ... (3 Replies)
I have a script that does an SSH into a remote node. It should expect the prompt and send the password.
#!/usr/bin/expect
set user ;
set pass ;
spawn ssh $user@E-Internal
expect {
-re "RSA key fingerprint" {send "yes\r"}
timeout... (1 Reply)
Ok, so I'm playing around with delimters and reading files. and I came across this behaviour that I thought was a bit odd, regarding how the set command takes values... If I run this: IFS=$'-' #Assigns the - as the default delimiter for bash set I-love-my-gf-a-lot #uses set to put a bunch of... (1 Reply)
Dear All,
I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
How can I pass password in SSH command without using expect in a shell program.
I don't have expect installed on my Solaris server.
#!/bin/bash
ssh user@hotname (how to supply pass in script?:wall:)
Experts please help its very urgent.
Shrawan Kumar Sahu (4 Replies)
Hello folks
I have a conf file ,say 'pass.conf' ,which is storing ascii password : PASS1111.
I need to encrypt this password once and store it in a file.
I ,then need to write a script which would read this encrypted password and decrypts it.The o/p o this script shud be this decrypted... (8 Replies)
Hi,
Normally, I setup my volumes under Solaris (doesnt matter, 8 or 10),
as vxassist -g dg01 -U gen make vol01 500m dg0101, then I do a mirror
vxassist -g dg01 mirror vol01 dg0102.
Which is legal and does work, however, when the primary dg01 array (or simply in this case, the volume)... (2 Replies)
Hi people,
I'm having some strange behaviour with an 'expect' script.
spawn csession blah
expect "Username: "
send "userblah\r"
expect "Password: "
send "passwordblah\r"
interact
When I execute the script as root it runs perfectly.
However, when executed as any other... (0 Replies)
I'm working with a java-based monitoring tool (Solaris/x86) which can be configured to call a shell script when a particular event occurs. The java app sends a set of quoted strings as input to the shell script.
The problem I'm running into is that the shell script, when called by the java app,... (0 Replies)
Could someone please help me...I have an expect script. There's a need for a log in during the script and a password is required...right now the password is just a variable in the expect script...what would be the best way to put that in an encrypted flat file and have the expect script pull the... (2 Replies)