HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Is possible to pass parameters to passwd command?
Operating System - HP-UX
1825771
Members
2171
Online
109687
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
01-25-2007 07:11 AM
01-25-2007 07:11 AM
Is possible to pass parameters to passwd command?
Hi,
I would like if its possible to pass one parameter to the passwd command.
The idea its to make one script passwd-chg (for example), and pass the name of the user to change and the new-passwd.... and the script will change it.... this is necessary because of I have one application that need to do that.
Does anyone if it is possible??
# passwd user < passwd1 passwd1 doesn't works ok.
Thanks very much.
Carmen.
I would like if its possible to pass one parameter to the passwd command.
The idea its to make one script passwd-chg (for example), and pass the name of the user to change and the new-passwd.... and the script will change it.... this is necessary because of I have one application that need to do that.
Does anyone if it is possible??
# passwd user < passwd1 passwd1 doesn't works ok.
Thanks very much.
Carmen.
Users are not too bad ;-)
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2007 07:34 AM
01-25-2007 07:34 AM
Re: Is possible to pass parameters to passwd command?
Not directly.
If it's an untrusted system, you can use /usr/lbin/makekey to create the hashed password that you can pass to /usr/sam/lbin/usermod.sam. Here's a start for what it would look like in your script:
#!/usr/bin/sh
set -A SEED A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9
USERNAME=$1
PASSWORD=$2
PASSWORD=$(echo ${PASSWORD} | grep "^[A-z0-9]\{8\}$")
SEEDIDX1=$((${#SEED[*]}*${RANDOM}/32767))
SEEDIDX2=$((${#SEED[*]}*${RANDOM}/32767))
if [ -n "${PASSWORD}" ]
then
KEY=${PASSWORD}${SEED[${SEEDIDX1}]}${SEED[${SEEDIDX2}]}
fi
UHASHPW="$(echo ${KEY} | /usr/lbin/makekey)"
/usr/sam/lbin/usermod.sam -p ${UHASHPW} ${USERNAME}
#############################################
If you're on a trusted system, I don't know that there's a similar utility to makekey that would generate an appropriate hash.
If it's an untrusted system, you can use /usr/lbin/makekey to create the hashed password that you can pass to /usr/sam/lbin/usermod.sam. Here's a start for what it would look like in your script:
#!/usr/bin/sh
set -A SEED A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9
USERNAME=$1
PASSWORD=$2
PASSWORD=$(echo ${PASSWORD} | grep "^[A-z0-9]\{8\}$")
SEEDIDX1=$((${#SEED[*]}*${RANDOM}/32767))
SEEDIDX2=$((${#SEED[*]}*${RANDOM}/32767))
if [ -n "${PASSWORD}" ]
then
KEY=${PASSWORD}${SEED[${SEEDIDX1}]}${SEED[${SEEDIDX2}]}
fi
UHASHPW="$(echo ${KEY} | /usr/lbin/makekey)"
/usr/sam/lbin/usermod.sam -p ${UHASHPW} ${USERNAME}
#############################################
If you're on a trusted system, I don't know that there's a similar utility to makekey that would generate an appropriate hash.
--
Jeff Traigle
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2007 07:50 AM
01-25-2007 07:50 AM
Re: Is possible to pass parameters to passwd command?
Shalom,
Here is how I would handle this.
vi list
add to it
user1
user2
user3
while read -r username
do
passwd $username
# insert code to do other things like change password without keyboard input.
done< list
SEP
Here is how I would handle this.
vi list
add to it
user1
user2
user3
while read -r username
do
passwd $username
# insert code to do other things like change password without keyboard input.
done< list
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2007 07:31 PM
01-26-2007 07:31 PM
Re: Is possible to pass parameters to passwd command?
# insert code to do other things like change password without keyboard input.
In general I've heard this means you need to use expect or set up a pipe.
In general I've heard this means you need to use expect or set up a pipe.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP