Skip to content

Instantly share code, notes, and snippets.

@BassyKuo
Created May 5, 2018 18:34
Show Gist options
  • Save BassyKuo/50da0ae6f3528b58f32a1ca43d0d6367 to your computer and use it in GitHub Desktop.
Save BassyKuo/50da0ae6f3528b58f32a1ca43d0d6367 to your computer and use it in GitHub Desktop.
Generate random password.
#!/bin/bash
#
# Uasge:
# getpasswd 64 ~/.vnc/passwd
#
length=${1:-128}
passwdfile=${2:-$HOME/.vnc/passwd}
if su -c true $USER ; then
head /dev/urandom | tr -dc 0-9a-zA-Z_ | head -c $length | tee /dev/tty | /usr/bin/vncpasswd -f > $passwdfile
echo ""
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment