문제

I use CentOS5. I'm trying to read a username and a password in a bash script so I can create a new unix user.

useradd -p $password $login

the problem here is that the password is not encrypted later in /etc/shadow.

In useradd man pages it is meant to specify passwords encrypted with crypt which is not a bash command. How can i use this function from a Bash script? Or is there any command for encrypting strings?

도움이 되었습니까?

해결책

You could use OpenSSL for this. Its passwd command uses crypt by default.

$ openssl passwd secret
xzQbh15rXTn1c
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top