Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 846
  • Last Modified:

how to change my password on remote maschines?

Hi,

i do have a user on a lot of system. And I have to change the password for this user on all systems. How could I do this using a (windows) script?
At the moment I do have a .bat file which calls putty for each server, but I have to enter
passwd
old password
new password
new password
exit
on every server.
There is no way to use certificates.. and I am not root, so
echo user:password | /usr/sbin/chpasswd
or
echo -e "newpasswd\nnewpasswd" | (passwd user)
does not work for me (as I could see).

Anybody any idea how to change the password for my remote user running a windows script.
At the moment I am testing with expect and ActiveTcl, but I am not sure if this leads to what I want, because ActiveTcl must be installed...
I hope for a batch file (where to enter user and (old/new) password) starting plink on a list of servers and changes the password.

Thank you.

Best regards
gnurl
0
gnurl
Asked:
gnurl
  • 5
  • 2
  • 2
  • +1
2 Solutions
 
farzanjCommented:
Are you trying to change password on Linux machines.
You can change password by issuing the following Linux command non interactively if you get the root shell.

The command is:
 
echo "Password" | passwd --stdin <USERID>

Open in new window

0
 
gnurlAuthor Commented:
Hi farzanj,

I do not get a root shell, i am a non priviled user wanting to change its password....
That is why I need to automate the interactive password change.

Best regards
gnurl
0
 
marinepaCommented:
you could generate ssh key on windows
copy public key on linux  HOME/.ssh/authorized_keys

now you could connect directly without password and then
change password using farzany hint above

bye

PS.

you could generate keys with putty or openssh for windows
ri-bye
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
expert_tanmayCommented:
cwRsync is a free distribution of the rsync utility that is optimized for quick and easy installation in Microsoft Windows. Download the latest version from here http://sourceforge.net/projects/sereds/files/cwRsync/

You have to set up your public/private keypair so that you are not prompted for password when your windows script connects. Read the documentation of how to do this.
You can also use putty the same way...

write a shell script on the Linux machine to change password. Write the script to take the username and the new password as arguments.
use the following to execute the script on linux to change password.
rsync --rsync-path=PROGRAM user new_passwd


Cheers..
0
 
gnurlAuthor Commented:
Hi,

I think I was misunderstood ... I am not really searching for a tool to start a linux script (this I could do with plink). I am searching for a possibility to change the (my) password with a script if I am not root.

If I issue echo -e "oldpasswd\nnewpasswd\nnewpasswd" | (passwd test)

I get a
echo -e "oldpasswd\nnewpasswd\nnewpasswd" | (passwd test)
Changing password for test.
Old Password: passwd: Authentication failure

Why do I get this error? Because I am logged in using username password? Or does passwd do not accept input from echo?

Thank you,
best regards
gnurl
0
 
farzanjCommented:
What you want to do may only be done using Expect/Auto Expect.

In Linux, if you are not the root user, you have to be interactive and there is no way around it.  You are not the root then you cannot use the non-interactive command that I sent you because that requires you to be root (non-root enabled with sudo access) no matter user password you want to change.  You want to automate it and that too interactively and the only way around that is Expect or Auto Expect.
0
 
expert_tanmayCommented:
Oh sorry I wanted to achieve your main objective of changing password on Linux machines without any manual intervention i.e. using a windows script. Also please note it is not necessary to be root to execute a script on Linux machine.

Cheers..
0
 
gnurlAuthor Commented:
Hi farzanj,

do you have a fast (good) howto or out of the box solution for this task with expect?
Whats the difference between expect and autoexpect?

Thanks a lot,
gnurl
0
 
gnurlAuthor Commented:
Hi all,

I am trying to use the expect from activeTCL and a mix from the original passmass script from (unix) expect and the remote.tcl from the examples of activeTCL-expect to get what I want.

Autoexpect cant be used, because it is not available in windows.
If the script will work I am going to try to complie this to an executable which can be accessed from a batch script...
maybe in some years I will see if this works...

Best regards
gnurl
0
 
gnurlAuthor Commented:
The explanation that only expect could do this is ok, but it does not solve my problem, I have to do a lot of work myself.

gnurl
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now