- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- add existing passwords to /etc/shadow
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2006 07:52 AM
06-20-2006 07:52 AM
add existing passwords to /etc/shadow
I can extract the encrypted password from the /etc/shadow on another server, but I'm having problems inserting it between the first and second colon ":".
But even before I do that, I need to remove what is already beween the first and second colon (:).
(colon).
I can't be the first person to do this. thx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2006 08:07 AM
06-20-2006 08:07 AM
Re: add existing passwords to /etc/shadow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2006 12:25 PM
06-20-2006 12:25 PM
Re: add existing passwords to /etc/shadow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2006 01:54 PM
06-20-2006 01:54 PM
Re: add existing passwords to /etc/shadow
Instead of trying to edit the /etc/passwd or /etc/shadow files on the target system directly (sed, awk, etc.), use the native commands that are provided to do it.
To add a new user w/encrypted password:
/usr/sbin/useradd -p '$1$cNAj3C63$eCYknWT349xrwT7/Fc936/' user1
To change password on existing user:
/usr/sbin/usermod -p '$1$cNAj3C63$eCYknWT349xrwT7/Fc936/' user1
You can use your awk/sed skills to parse/capture the encrypted passwords from /etc/shadow on your source system into a temp file, then build a little shell script to loop through each temp record executing either "useradd" or "usermod" (depending on whether your target users already exist or not).
Regards,
Jared
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2006 02:27 PM
06-20-2006 02:27 PM
Re: add existing passwords to /etc/shadow
#!/usr/bin/ksh
#Usage: sync.sh
SHADOW=/etc/shadow #a copy from old server
FILE=$1
for i in `cat $FILE`
do
SHADOWENTRY=`grep "${i}" ${SHADOW}`
ENCRYPT=`echo ${SHADOWENTRY} | awk -F: '{print $2}'`
/usr/sbin/useradd -p ${ENCRYPT} ${i}
#You can also try using chpasswd -e below just uncomment
#echo "${i}:${ENCRYPT}" | chpasswd -e && chage -m 7 -M 90 -W 14 ${i} > /dev/null
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2006 12:38 AM
06-21-2006 12:38 AM