From 50743795082a1cba478850bb22bd2093e214c9df Mon Sep 17 00:00:00 2001 From: Dinh Phu Nguyen Date: Tue, 12 Nov 2024 22:28:43 +0700 Subject: [PATCH 1/4] Add draft post generate-password-cli Signed-off-by: Dinh Phu Nguyen --- _drafts/2024-11-09-generate-password-cli.md | 59 +++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 _drafts/2024-11-09-generate-password-cli.md diff --git a/_drafts/2024-11-09-generate-password-cli.md b/_drafts/2024-11-09-generate-password-cli.md new file mode 100644 index 0000000..376abad --- /dev/null +++ b/_drafts/2024-11-09-generate-password-cli.md @@ -0,0 +1,59 @@ +--- +layout: post +title: Generate password with command line in Linux or macOS +date: 2024-11-09 16:16:00-0700 +description: If you usually work with command line in Linux or macOS, you can use it to generate password without installing any additional application. +tags: cli password-generating command-line linux macos +categories: utilities +giscus_comments: true +related_posts: false +toc: + beginning: true +--- + +Most websites or application require a strong password that contains a mix of letters, numbers and special characters. And to make it more secure, it should be unique and randomly generated for each account. +If you are using Linux or macOS and usually work with command line, you can use it to generate without installing any additional application. + +### Using /dev/urandom or /dev/random + +This is my favorite way to generate password because `/dev/urandom` and `/dev/random` are available in most Unix-like operating systems. + +```sh +< /dev/urandom tr -dc '[:graph:]' | head -c32; echo +``` + +This command will create a random password with printable character, length is 32. + +In case that alphabet & numeric character, use `alnum` instead of `graph`. + +For more information, see `tr` [manpage](https://linuxcommand.org/lc3_man_pages/tr1.html) + +With macOS, an error occur when run above command because of UTF-8. Just add LC_ALL=C as below: + +```sh +< /dev/urandom LC_ALL=C tr -dc '[:graph:]' | head -c32; echo +``` + +For more security, I suggest using /dev/urandom because it is really a random value, but in case that ... + +### Using openssl + +```sh +openssl rand -base64 32 +``` + +This command can only generate a base64 string password. + +### Using date and hashing + +```sh +date | md5 +``` + +It similar to openssl command, but it's not really random like openssl or /dev/urandom. + +### Using gpg + +```sh +gpg --gen-random 1 32 +``` From 194b971457e465e94c6e556ce6e72ee750525e1e Mon Sep 17 00:00:00 2001 From: Dinh Phu Nguyen Date: Wed, 13 Nov 2024 11:45:54 +0700 Subject: [PATCH 2/4] Update draft post Generate Password CLI Signed-off-by: Dinh Phu Nguyen --- _drafts/2024-11-09-generate-password-cli.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/_drafts/2024-11-09-generate-password-cli.md b/_drafts/2024-11-09-generate-password-cli.md index 376abad..5a51c31 100644 --- a/_drafts/2024-11-09-generate-password-cli.md +++ b/_drafts/2024-11-09-generate-password-cli.md @@ -34,7 +34,17 @@ With macOS, an error occur when run above command because of UTF-8. Just add LC_ < /dev/urandom LC_ALL=C tr -dc '[:graph:]' | head -c32; echo ``` -For more security, I suggest using /dev/urandom because it is really a random value, but in case that ... +#### Random + +/dev/random takes the random values from the entropy pool. If the entropy pool is empty, it will be blocked reading. + +#### URandom (Unlimited Random) + +/dev/urandom is similar to /dev/random but in case that entropy pool is empty, it generate value using hashing argorithm such as: SHA, MD5, ... + +#### In term of security + +Because of high-quality randomness of /dev/random, it's suitable for a password or a task focus on security. ### Using openssl From dd6022f937c673610e74c3f2ba41747a492c3b44 Mon Sep 17 00:00:00 2001 From: Dinh Phu Nguyen Date: Wed, 13 Nov 2024 11:47:28 +0700 Subject: [PATCH 3/4] Publish post Generate Password CLI Signed-off-by: Dinh Phu Nguyen --- {_drafts => _posts}/2024-11-09-generate-password-cli.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {_drafts => _posts}/2024-11-09-generate-password-cli.md (100%) diff --git a/_drafts/2024-11-09-generate-password-cli.md b/_posts/2024-11-09-generate-password-cli.md similarity index 100% rename from _drafts/2024-11-09-generate-password-cli.md rename to _posts/2024-11-09-generate-password-cli.md From 9e05c0826dda8fdd919ac086efe931e6ad004ab6 Mon Sep 17 00:00:00 2001 From: Dinh Phu Nguyen Date: Wed, 13 Nov 2024 11:49:03 +0700 Subject: [PATCH 4/4] Unpublish post solid-principles & redirect Signed-off-by: Dinh Phu Nguyen --- {_posts => _drafts}/2022-02-01-redirect.md | 0 {_posts => _drafts}/2024-03-27-solid-principles.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {_posts => _drafts}/2022-02-01-redirect.md (100%) rename {_posts => _drafts}/2024-03-27-solid-principles.md (100%) diff --git a/_posts/2022-02-01-redirect.md b/_drafts/2022-02-01-redirect.md similarity index 100% rename from _posts/2022-02-01-redirect.md rename to _drafts/2022-02-01-redirect.md diff --git a/_posts/2024-03-27-solid-principles.md b/_drafts/2024-03-27-solid-principles.md similarity index 100% rename from _posts/2024-03-27-solid-principles.md rename to _drafts/2024-03-27-solid-principles.md