본문 바로가기

컴터 때찌/E​xperience

useradd + passwd

[CentOS/RHEL]
useradd -m -d /home/$i $i
echo $i | passwd --stdin $i

#!/bin/bash
useradd $1
echo $2 | passwd --stdin $1

It seams the --stdin option does not exist under Ubuntu.
You can write input in prog's stdin like ssh or passwd using socat but I think there is an easier way to do what you want.
CENTOS/RHEL support the --stdin option. Appears Debian and it's variants like Ubuntu do not.

[Ubuntu ]
prometeo -p `mkpasswd someword`

#!/bin/bash
useradd $1 -p `mkpasswd $2`

[usage]
# sh leo.sh leo8 leopasswd


'컴터 때찌 > E​xperience' 카테고리의 다른 글

mysql 5.5 GA release  (0) 2010.12.18
Linux Kernel <= 2.6.37 Local Privilege Escalation  (0) 2010.12.08
Adobe Flash Player 10.1.102.64 vul  (0) 2010.11.09
About Ubuntu  (1) 2010.11.03
Local File Inclusion&Remote File Inclusion  (0) 2010.10.20