Solved

how to change my password on remote maschines?

Posted on 2011-03-09
10
819 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

707 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

16 Experts available now in Live!

Get 1:1 Help Now