Solved

how to change my password on remote maschines?

Posted on 2011-03-09
10
822 Views
Last Modified: 2013-12-05
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
Comment
Question by:gnurl
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 35094606
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
 
LVL 7

Author Comment

by:gnurl
ID: 35094922
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
 
LVL 3

Expert Comment

by:marinepa
ID: 35099034
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
 
LVL 9

Expert Comment

by:expert_tanmay
ID: 35103917
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
 
LVL 7

Author Comment

by:gnurl
ID: 35107641
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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 31

Accepted Solution

by:
farzanj earned 500 total points
ID: 35107973
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
 
LVL 9

Expert Comment

by:expert_tanmay
ID: 35114097
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
 
LVL 7

Author Comment

by:gnurl
ID: 35125639
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
 
LVL 7

Assisted Solution

by:gnurl
gnurl earned 0 total points
ID: 35283957
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
 
LVL 7

Author Closing Comment

by:gnurl
ID: 35321776
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now