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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
![Reply](https://www.linuxquestions.org/questions/images/buttons/reply.gif) |
10-18-2007, 02:00 PM
|
#1
|
Member
Registered: Sep 2007
Posts: 61
Rep:
|
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.
|
|
|
10-18-2007, 02:40 PM
|
#2
|
Senior Member
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109
Rep:
|
Hi.
Try:
Code:
echo n3wP4ssW0rd | passwd --stdin christopher_c
Dave
|
|
|
10-18-2007, 02:55 PM
|
#3
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
10-18-2007, 02:57 PM
|
#4
|
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131
Rep: ![Reputation: Disabled](https://www.linuxquestions.org/questions/images/reputation/reputation_off.gif)
|
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.
|
|
|
10-18-2007, 03:00 PM
|
#5
|
Senior Member
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109
Rep:
|
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.
|
|
|
10-18-2007, 03:47 PM
|
#6
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
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.
|
|
|
10-18-2007, 03:51 PM
|
#7
|
Senior Member
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109
Rep:
|
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.
|
|
|
10-18-2007, 04:10 PM
|
#8
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
10-18-2007, 04:17 PM
|
#9
|
Senior Member
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109
Rep:
|
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
|
|
|
10-18-2007, 04:21 PM
|
#10
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Quote:
Originally Posted by ilikejam
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)
|
|
|
10-18-2007, 04:46 PM
|
#11
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
Kubuntu 7.04 doesn't recognise --stdin.
|
|
|
10-19-2007, 01:26 AM
|
#12
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,419
|
Try the expect tool, it's designed to handle ie automate issues like this
|
|
|
All times are GMT -5. The time now is 04:46 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|