DEV Community

Sabito
Sabito

Posted on

Generate Secure Passwords Using Built-in Tools on macOS, Windows, and Ubuntu

In today's computing environment, password security is paramount. Different operating systems offer their own tools to generate complex passwords. This article will show you how to use built-in tools on macOS, Windows, and Ubuntu to create secure passwords.

How to Generate Complex Passwords on macOS

Terminal:

  • Use the openssl command to generate a random password:

     openssl rand -base64 16
    

For convenience, you can further package this method into a right-click shortcut using Automator

Automator:

  • Open Automator (found in “Applications”).
  • Choose the “Service” template.
  • Search for and add the “Run Shell Script” action, then paste the following script:

     /usr/bin/openssl rand -base64 16
    
  • Save the service, naming it “Generate Random Password.” You can then use it by right-clicking and selecting “Services” -> “Generate Random Password.”

How to Generate Complex Passwords on Windows

PowerShell:

  • Open PowerShell.
  • Use the following command to generate a random password:

     Add-Type -AssemblyName System.Web
     [System.Web.Security.Membership]::GeneratePassword(16,3)
    

Command Prompt:

  • Use the certutil command to generate random data and convert it to base64:

     certutil -encodehex -f nul - 48 | findstr /v /c:"CertUtil" /c:"48 bytes" /c:"\---" | powershell -Command "$input | ForEach-Object { $_.Trim() }" | out-string | format-hex -u
    

How to Generate Complex Passwords on Ubuntu

OpenSSL:

  • Use the openssl command to generate a random password:

     openssl rand -base64 16
    

/dev/urandom:

  • Use /dev/urandom to generate random data and convert it to base64:

     < /dev/urandom tr -dc A-Za-z0-9 | head -c 16 ; echo ''
    

By using these built-in tools, you can easily generate complex passwords and ensure your accounts are secure.

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay