LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-18-2007, 01:00 PM   #1
christopher_c
Member
 
Registered: Sep 2007
Posts: 61

Rep: Reputation: 15
Change account passwd in one command


Hey everyone

is it possible to change an account password without having to type it in twice like the 'passwd' command does?(ie verify)

I checked the man pages for passwd but doesnt seem to have an option to do so.
 
Old 10-18-2007, 01:40 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

Try:
Code:
echo n3wP4ssW0rd | passwd --stdin christopher_c
Dave
 
Old 10-18-2007, 01:55 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Caution: not all versions of passwd understand the --stdin. The one
in Slackware (from shadow-4.0.3-i486-14) doesn't. Neither does the one
in SLES, nor the one in Solaris 8 or 10...

Which version of Linux *DOES*? :}



Cheers,
Tink
 
Old 10-18-2007, 01:57 PM   #4
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Only the above method isn't too safe, because you type the password in clear-text, and secondly because it's pretty surely saved into command history of your shell. You can always remove the history file, but I still don't recommend typing passwords in clear-text.
 
Old 10-18-2007, 02:00 PM   #5
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hmmm.

RedHat/Fedora's understands --stdin , but only allows it for root (so the security hazard from shell histories is somewhat lessened).

Another RedHatism, it would appear. I thought these sorts of differences went away a long time ago too...

An alternative (assuming you don't care about the afore mentioned shell history / ps listing issue) is to do
Code:
echo -e 'n3wP4ssW0rd\nn3wP4ssW0rd' | passwd christopher_c
Dave

Last edited by ilikejam; 10-18-2007 at 02:07 PM.
 
Old 10-18-2007, 02:47 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
this is one of those things that's nice to know, but not a good idea to actually DO....If you are "very clever", you can make it easy to make a typo in your password and then get locked out of your system.

It strikes me that the solution being discussed will take more time to type than simply entering the password twice.
 
Old 10-18-2007, 02:51 PM   #7
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Think large scale deployment.
Code:
for go in `cat bigListOfServersWithPasswordlessSSHKeys`; do ssh $go "echo -e 'n3wP4ssW0rd\nn3wP4ssW0rd' | passwd christopher_c"; done
I wish we were able to do this sort of thing from a secured box at work. It would save me ~3 hours repetative strain injury time a month.

Dave

Last edited by ilikejam; 10-18-2007 at 02:55 PM.
 
Old 10-18-2007, 03:10 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
I appreciate that LDAP or NIS/NIS+ may not be an option for everyone or every
account, so the brute distribution of passwords can make sense.

Why not change the password on one machine and then sed it with the method above
in the shadow files on the target machines? ;}



Cheers,
Tink
 
Old 10-18-2007, 03:17 PM   #9
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
I like the way you think.

There'd have to be some jiggery-pokery with the password expire times too though. Also, a mix of AIX, Sol8,9,10 and Linux would make it a bit more horrific.

Dave
 
Old 10-18-2007, 03:21 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Quote:
Originally Posted by ilikejam View Post
I like the way you think.

There'd have to be some jiggery-pokery with the password expire times too though. Also, a mix of AIX, Sol8,9,10 and Linux would make it a bit more horrific. ;)


Dave
Heh. That's three loops, then, one for each OS-type ;} with a
somewhat different incantation ...



Cheers,
Tink (inherently lazy - slacker for life)
 
Old 10-18-2007, 03:46 PM   #11
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Kubuntu 7.04 doesn't recognise --stdin.
 
Old 10-19-2007, 12:26 AM   #12
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
Try the expect tool, it's designed to handle ie automate issues like this
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Passwd Format shipon_97 Linux - Newbie 1 01-09-2007 08:13 AM
change passwd using squirrelmail shipon_97 Linux - Enterprise 1 12-29-2006 08:53 PM
Initial passwd change liguorir Linux - Software 0 09-24-2004 11:01 AM
Disable passwd change for user account sodhilogin Linux - General 6 09-01-2004 12:43 AM
need a script that can change the passwd bahadur Linux - Security 1 07-09-2004 05:07 AM


All times are GMT -5. The time now is 06:27 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration