lebt in der Schweiz, ist System Engineer MCP bei A-Enterprise GmbH. Mitglied des UNBLOG Knowledge Network. Author und Blogger zu den Themen, Tutorials für Linux und Open Source.
In this tutorial, you’ll learn how to quickly and easily generate strong and secure passwords for multiple accounts or in the web using random password generator in Windows PowerShell.
PowerShell provides a way to quickly generate random passwords to save time and protect your data. In this post, you will learn how to generate random passwords with different length and complexity requirements using PowerShell commands.
Supporting a random password generator in PowerShell has several benefits. It ensures that the generated passwords are truly random, making them more secure from brute-force attacks than passwords based on predictable patterns or personal information. Additionally, a random password generator allows for automation, making it ideal for scenarios where you need to quickly generate multiple passwords, such as creating user accounts in active directory or setting up service accounts. By using PowerShell, you can create complex and unique passwords without the need for additional tools.
Based on the command known from *nix systems, I call it mkpasswd.
Save the lines in the file Microsoft.PowerShell_profile.ps1
The file Microsoft.PowerShell_profile.ps1 must be in the user’s Documents folder, under the WindowsPowerShell folder.
"%USERPROFILE%\Documents\WindowsPowerShell"
This mkpasswd function takes two parameters. The length parameter determines the length of the password, while the NumberOfSpecialChars parameter specifies the number of special characters in the password. By changing these parameters, you can generate passwords that meet your needs.
How to generate a secure password in PowerShell
Open PowerShell and run the password generator with entermkpasswdand hit Enter
PS C:\> mkpasswd 12
SIaWH2kj}iZ$
The number indicates the lenght of the password should have. Without specifying the password length, the prompt asks you to enter a number.
Hit. use this one-liner to quick generate a secure password.
Generating strong passwords is an essential part of connected security in today’s global world. Luckily, you don’t have to spend hours struggling with complex passwords when you can easily generate them using PowerShell commands. With just a few actions you can quickly create random passwords that meet current security standards. This way we keep prying eyes away from our data.
Generate Random Password using Strong Password Generator
You can manually create some of the passwords you need. However, if you want to generate a secure password for multiple users or devices, then this is not an adequate approach.
There are many Linux utilities on the web that meet these requirements. In this tutorial I will introduce the 10 best password generators, which can be used in the Linux terminal.
The following combinations will help you generate a strong password. It should be at least 10-16 characters long, including alphabets (lowercase and uppercase), numbers, and special characters.
The 10 best strong password generators
pwgen generate strong passwords that are easy for people to remember and at the same time as secure as possible. xkcdpass uses 12 dictionaries by Aspell, the GNU spell checker project. openssl commonly used for the various cryptography operations of OpenSSL cryptography library. gpg used the OpenPGP encryption and signing tool. mkpasswd create new password, can optionally be applied to a user. makepasswd create true randomized passwords using /dev/urandom, with the accent on security over pronounceability. md5sum calculates and verifies 128-bit MD5 hashes. sha256sum verify data integrity using the SHA-256. sha1pass is known to create SHA1 hash. /dev/urandom file use character special files /dev/random to provide an interface to the kernel random number generator.
Generate strong password using pwgen
The pwgen program generates passwords in a way that people can easily remember, while being as secure as possible. For most systems, pwgen needs to be installed first.
$ sudo apt install pwgen
To do so, simple run the pwgen command in the Linux terminal. It generates 160 secure passwords in a single shot. These 160 passwords are printed in 20 rows and 8 columns.
Generate strong 6 passwords with 16 characters length. Use -s option to generate completely random, hard-to-memorize words. Run the pwgen command as follows.
xkcdpass uses the dict2 and dict6 word list by default due to their unique properties. It has an option that could be used. It can be combined with the output of pwgen to get unique passwords too. You can also use the first letter of each word of the passphrase to create a password that is also easy to remember.
Commonly the xkcdpass program has to be installed first.
$ sudo apt install xkcdpass
If you hit and run xkcdpass then 6 passwords will be displayed.
xkcdpass can even be used interactively, with the -i option it asks you how many words it should generate and whether it should continue generating with ask y/N and loop until one is accepted.
$ xkcdpass -i
Enter number of words (default 6): 12
Generated: employer celibacy hypertext liqueur bounce tightrope probiotic pencil provoke spotless jawless endnote
Accept? [yN] n
Generated: concrete edginess reanalyze hatred possibly tadpole reword fresh glory casually duckling overstuff
Accept? [yN] y
concrete edginess reanalyze hatred possibly tadpole reword fresh glory casually duckling overstuff
Create random password using OpenSSL
Using OpenSSL to create secure passwords, with run the following command to create a random password with 16 characters lenght.
Using /dev/urandom, the special character files /dev/random and /dev/urandom provide an interface to the kernel random number generator. The file /dev/random has the major device number 1 and the minor device number 8. The file /dev/urandom has the major device number 1 and the minor device number 9.