Solved

Setting passwd from a ksh script

Posted on 1998-10-21
7
451 Views
Last Modified: 2010-08-05
Is it possible to set a password from within a shell script. I can't seem to find any way to pass the new password to the passwd command. It still will always ask for New Password:.
0
Comment
Question by:johnnyw
  • 3
  • 3
7 Comments
 
LVL 1

Accepted Solution

by:
Strange earned 100 total points
ID: 2007516
If your script can be executed by the root or be setuided, you can simply correct master.passwd file without using passwd command. There is an 'adduser' script under FreeBSD that doing many such a things.
0
 

Author Comment

by:johnnyw
ID: 2007517
The script will be run as root. It's running under Sequent Dynix/Ptx 4.4.2. If you can tell me where I can get hold of the script you mention I'll evaluate it. My other alternative is to pass in the encrypted password as a string using the passmgmt command.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007518
UNIX does not allow to pass the password as argument or read it from a file (input redirect) 'cause of security reason.
To do such things you need expect.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:johnnyw
ID: 2007519
Cheers. Looking at the expect documentation that will seem to do the trick.

Thanks very much.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007520
So you accepted my comment but a "Strange" answer was graded,
bad luck (for me :-)
0
 

Author Comment

by:johnnyw
ID: 2007521
Sorry I wasn't reading them correctly. I'm new to this site so wasn't paying enough attention.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007522
I'll survive :-)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now