?
Solved

how to change my password on remote maschines?

Posted on 2011-03-09
10
Medium Priority
?
836 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
LVL 31

Accepted Solution

by:
farzanj earned 2000 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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

770 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