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 03-27-2015, 08:32 AM   #1
wowy
Member
 
Registered: Mar 2015
Location: France
Distribution: Ubuntu 14.04
Posts: 61

Rep: Reputation: Disabled
How do i edit passwd and shadow to encrypt the password of an user ?


Hi,

Right now on my system i have 5/6 users in my /etc/passwd file but all of them are in clear.
I know that normally encrypted passwords are in /etc/shadow and i know that the commands cryptpw and mkpasswd can be used to encrypt a string of character.

If for example an user is like this in passwd :

banana:lasagna:3:0:food:/:/bin/sh

Do i have to edit manually the shadow file with the encrypted string corresponding to "lasagna" here ? And what must i write in this shadow file ?

Thank you for the future answers !
 
Old 03-27-2015, 11:21 AM   #2
JeremyBoden
Senior Member
 
Registered: Nov 2011
Distribution: Debian
Posts: 1,183

Rep: Reputation: 243Reputation: 243Reputation: 243
You don't manually change the passwd file or its shadow.
If you could easily do this, then you would have a gaping security hole.

See the passwd and group commands.
 
Old 03-27-2015, 12:32 PM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
We use 'pwconv' and 'grpconv' from shadow package.
 
Old 03-27-2015, 12:35 PM   #4
fatmac
Senior Member
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: AntiX
Posts: 1,950

Rep: Reputation: Disabled
You may find you have vipw for editing your password files.
 
Old 03-27-2015, 12:49 PM   #5
cepheus11
Member
 
Registered: Nov 2010
Location: Germany
Distribution: Gentoo
Posts: 285

Rep: Reputation: 89
If the password is in clear text in passwd, something went wrong while creating the user or setting the password. You seem to be posting from Ubuntu 14.04. Every modern general-purpose distribution should be using "shadow utilities" by now. I just checked on Ubuntu 14.04: Got root shell, created new user with

Code:
useradd -m -G cdrom,plugdev,sambashare test
and set password with

Code:
passwd test
And the password is not stored in passwd or shadow. A checksum of the password (and salt) is stored in shadow. The second column in passwd just contains "x". That is how it should be.

That raises the question: How did you create your users? Did you change something in /etc/login.defs?

Possibly quickest solution: Re-create the passwords with passwd. If everything is configured right, it should store checksums instead of clear passwords.
 
  


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
Editing root password /etc/passwd and /etc/shadow is not working thething Linux - Security 2 08-25-2014 02:37 AM
How can i check a string with actual user passwd (ie password in /etc/shadow) iamjayanth Linux - Software 6 09-29-2009 02:34 AM
user password failed after migrating /etc/shadow, /etc/passwd ect from SUSE9 to CenOS monkeyxu Linux - Newbie 1 05-21-2009 10:42 AM
How to encrypt a password to the /etc/shadow file? Milosevic Linux - Newbie 2 12-13-2005 03:14 PM
Encrypt password for /etc/shadow - SunOS liguorir Linux - Software 1 05-06-2004 11:28 PM

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

All times are GMT -5. The time now is 10:40 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration