Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I change root password with one line command on NetBSD? On FreeBSD, it's something like this

echo "password" | pw mod user root -h 0 ;
share|improve this question
    
This could be the way of doing it:mail-index.netbsd.org/netbsd-users/2002/08/03/0005.html –  nwildner Jun 14 '13 at 14:15

2 Answers 2

NetBSD does not support the pw command in its default install. You can:

  1. Compile the pw command for NetBSD and install it on your systems
  2. Write a utility that performs the equivalent functionality
  3. Update the password by manipulating the shadow file directly

Note that depending on your script you should probably be using -H (and supplying an appropriately-encrypted password) instead of -h.
Passing unencrypted passwords around the system (especially if you're doing something like echo "password") is a Bad Idea as it can result in exposing your password to any logged in user (or service).

share|improve this answer

Use usermod with -p switch. It's included with base system, no need to build pw.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.