If you need to set a password from a command line automatically, you can use the following script:
echo myPassword | passwd myUser --stdin
This will ensure your password is send via pipe into passwd and set appropriately. It can be useful when you need to assign same password on different servers, so you can run this command remotely, over ssh.
A blog about tips and tricks for linux - as I do some development, sometimes I find some good staff which I would like to store somewhere. I will be happy if you find this stuff to be useful for any reason.
Showing posts with label password. Show all posts
Showing posts with label password. Show all posts
Wednesday, April 22, 2015
Friday, November 7, 2014
Random password in bash
Sometimes you may need to generate some random password. Bash can help you with that task. For any of the commands below you can modify them to adjust to your needs, i.e. modify the length or the logic.
16-character-long password based on date and base64/SHA encoding:
Another example using built-in /dev/urandom command:
Now the simplest command, which will work in any environment.
16-character-long password based on date and base64/SHA encoding:
date +%s | base64 | sha256sum | head -c 16 ; echoAnother example using built-in /dev/urandom command:
< /dev/urandom tr -dc a-zA-Z-0-9 | head -c 16 ; echo;Now the simplest command, which will work in any environment.
date | md5sumdate | md5sum | head -c 8
Subscribe to:
Posts (Atom)