Advertisement
retnet

Membuat user SSH interaktif (interactive)

Mar 25th, 2015
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. #!/bin/bash
  2. # Script to add a user to Linux system
  3. if [ $(id -u) -eq 0 ]; then
  4.         read -p "Masukkan username : " username
  5.         read -s -p "Masukkan password : " password
  6.         egrep "^$username" /etc/passwd >/dev/null
  7.         if [ $? -eq 0 ]; then
  8.                 echo "$username Sudah Ada!"
  9.                 exit 1
  10.         else
  11.                 pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
  12.                 useradd -M -p $pass $username
  13.                 [ $? -eq 0 ] && echo "User telah berhasil dibuat!" || echo "Gagal menambah user!"
  14.         fi
  15. else
  16.         echo "gak oleh rek, iki dudu jatah mu gawe user"
  17.         exit 2
  18. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement