LinuxQuestions.org
Help answer threads with 0 replies.
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, 02: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, 02:40 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

Try:
Code:
echo n3wP4ssW0rd | passwd --stdin christopher_c
Dave
 
Old 10-18-2007, 02:55 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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, 02:57 PM   #4
b0uncer
LQ 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, 03:00 PM   #5
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
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 03:07 PM.
 
Old 10-18-2007, 03:47 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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, 03:51 PM   #7
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
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 03:55 PM.
 
Old 10-18-2007, 04:10 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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, 04:17 PM   #9
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
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, 04:21 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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, 04:46 PM   #11
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 67
Kubuntu 7.04 doesn't recognise --stdin.
 
Old 10-19-2007, 01:26 AM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,419

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
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 09:13 AM
change passwd using squirrelmail shipon_97 Linux - Enterprise 1 12-29-2006 09:53 PM
Initial passwd change liguorir Linux - Software 0 09-24-2004 12:01 PM
Disable passwd change for user account sodhilogin Linux - General 6 09-01-2004 01:43 AM
need a script that can change the passwd bahadur Linux - Security 1 07-09-2004 06:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:46 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration