Generate random password with special characters on Solaris

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I am trying to generate a 10-character random password in Solaris servers. The examples give around the web are for Linux and mostly not working in Solaris.







share|improve this question





















  • mostly not working in solaris
    – judi
    May 8 at 11:35






  • 1




    “10 digits” contradicts “special character”. What is your exact requirement? Edit your question. Your question may or may not end up being a duplicate of this depending on what you need.
    – Gilles
    May 8 at 11:41











  • Thanks - the password should be 10 characters - Alpha + Numeric+ Special character
    – judi
    May 8 at 11:59






  • 1




    A list of commands you tried and any output / error messages you got (and what you expected instead) might help to understand your issue.
    – frostschutz
    May 8 at 12:14














up vote
1
down vote

favorite












I am trying to generate a 10-character random password in Solaris servers. The examples give around the web are for Linux and mostly not working in Solaris.







share|improve this question





















  • mostly not working in solaris
    – judi
    May 8 at 11:35






  • 1




    “10 digits” contradicts “special character”. What is your exact requirement? Edit your question. Your question may or may not end up being a duplicate of this depending on what you need.
    – Gilles
    May 8 at 11:41











  • Thanks - the password should be 10 characters - Alpha + Numeric+ Special character
    – judi
    May 8 at 11:59






  • 1




    A list of commands you tried and any output / error messages you got (and what you expected instead) might help to understand your issue.
    – frostschutz
    May 8 at 12:14












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am trying to generate a 10-character random password in Solaris servers. The examples give around the web are for Linux and mostly not working in Solaris.







share|improve this question













I am trying to generate a 10-character random password in Solaris servers. The examples give around the web are for Linux and mostly not working in Solaris.









share|improve this question












share|improve this question




share|improve this question








edited May 8 at 12:31









Gilles

503k1189951522




503k1189951522









asked May 8 at 11:34









judi

216




216











  • mostly not working in solaris
    – judi
    May 8 at 11:35






  • 1




    “10 digits” contradicts “special character”. What is your exact requirement? Edit your question. Your question may or may not end up being a duplicate of this depending on what you need.
    – Gilles
    May 8 at 11:41











  • Thanks - the password should be 10 characters - Alpha + Numeric+ Special character
    – judi
    May 8 at 11:59






  • 1




    A list of commands you tried and any output / error messages you got (and what you expected instead) might help to understand your issue.
    – frostschutz
    May 8 at 12:14
















  • mostly not working in solaris
    – judi
    May 8 at 11:35






  • 1




    “10 digits” contradicts “special character”. What is your exact requirement? Edit your question. Your question may or may not end up being a duplicate of this depending on what you need.
    – Gilles
    May 8 at 11:41











  • Thanks - the password should be 10 characters - Alpha + Numeric+ Special character
    – judi
    May 8 at 11:59






  • 1




    A list of commands you tried and any output / error messages you got (and what you expected instead) might help to understand your issue.
    – frostschutz
    May 8 at 12:14















mostly not working in solaris
– judi
May 8 at 11:35




mostly not working in solaris
– judi
May 8 at 11:35




1




1




“10 digits” contradicts “special character”. What is your exact requirement? Edit your question. Your question may or may not end up being a duplicate of this depending on what you need.
– Gilles
May 8 at 11:41





“10 digits” contradicts “special character”. What is your exact requirement? Edit your question. Your question may or may not end up being a duplicate of this depending on what you need.
– Gilles
May 8 at 11:41













Thanks - the password should be 10 characters - Alpha + Numeric+ Special character
– judi
May 8 at 11:59




Thanks - the password should be 10 characters - Alpha + Numeric+ Special character
– judi
May 8 at 11:59




1




1




A list of commands you tried and any output / error messages you got (and what you expected instead) might help to understand your issue.
– frostschutz
May 8 at 12:14




A list of commands you tried and any output / error messages you got (and what you expected instead) might help to understand your issue.
– frostschutz
May 8 at 12:14










2 Answers
2






active

oldest

votes

















up vote
3
down vote













You can get cryptographic-quality random bytes from /dev/urandom. (This exists since Solaris 9. It also exists on Linux.) This includes unprintable characters, so you need to remove those. The following command extracts 10 random printable, non-space ASCII characters.



</dev/urandom tr -dc '!-~' | dd ibs=1 obs=1 count=10


I don't recommend using special characters in passwords. They don't make passwords more secure. What makes the security of a password is its entropy. A 10-character password has 10×log2(94) ≈ 65.5 bits of entropy. You can get the same amount of entropy from 9 arbitrary bytes and encode them as you wish, for example as hexadecimal.



</dev/urandom dd ibs=1 obs=1 count=9 | od -tx1 -An | tr -d ' '


Or as Base64, which is shorter.



</dev/urandom dd ibs=1 obs=1 count=9 | uuencode -m - | sed -n 2p


If there's some hard constraint that “passwords must contain at least one special character” (which is a questionable way to make passwords selected by average humans more secure, and it completely wrong for randomly generated passwords), then you can't simply use a random password, because there's a chance that it'll happen not to contain any character in a required class. If you reject passwords that don't meet the constraint, you're reducing the security of the password. Instead, make the password longer, e.g.



</dev/urandom dd ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/'


If you need the password to be memorable, that's a different problem. The best memorable passwords are passphrases.






share|improve this answer





















  • can this stdd in and out be removed please sol10 # dd if=/dev/urandom ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/' 9+0 records in 9+0 records out A9xk0r4MvMCY-Aa1 sol10 #
    – judi
    May 8 at 14:06











  • Thanks Much , this will eliminate the dd command output. dd if=/dev/urandom ibs=1 obs=1 count=9 2>/dev/null | uuencode -m - | sed '2!d; s/$/-Aa1/'
    – judi
    May 8 at 14:20


















up vote
-1
down vote













You have perl in Solaris, it helps:



perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10'


With special characters it will be:



perl -e 'print [0..9,a..z,A..Z,qw- _ / & ?]->[rand 67]for 0..10'





share|improve this answer























  • Thanks - but there is no special characters. sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' e9RKUJiss3 sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' zLdxvTqlJT sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' AiaiDubgye sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' lJxiV2iDwY sol10 #
    – judi
    May 8 at 12:01











  • You may add special characters in such way: perl -e 'print [a..z,A..Z,0..9,qw- _ / & ?]->[rand 67]for 0..10'
    – Sasha Golikov
    May 8 at 12:24







  • 1




    No, Perl's rand is not suitable to generate a password. This answer is insecure.
    – Gilles
    May 8 at 12:31










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442519%2fgenerate-random-password-with-special-characters-on-solaris%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













You can get cryptographic-quality random bytes from /dev/urandom. (This exists since Solaris 9. It also exists on Linux.) This includes unprintable characters, so you need to remove those. The following command extracts 10 random printable, non-space ASCII characters.



</dev/urandom tr -dc '!-~' | dd ibs=1 obs=1 count=10


I don't recommend using special characters in passwords. They don't make passwords more secure. What makes the security of a password is its entropy. A 10-character password has 10×log2(94) ≈ 65.5 bits of entropy. You can get the same amount of entropy from 9 arbitrary bytes and encode them as you wish, for example as hexadecimal.



</dev/urandom dd ibs=1 obs=1 count=9 | od -tx1 -An | tr -d ' '


Or as Base64, which is shorter.



</dev/urandom dd ibs=1 obs=1 count=9 | uuencode -m - | sed -n 2p


If there's some hard constraint that “passwords must contain at least one special character” (which is a questionable way to make passwords selected by average humans more secure, and it completely wrong for randomly generated passwords), then you can't simply use a random password, because there's a chance that it'll happen not to contain any character in a required class. If you reject passwords that don't meet the constraint, you're reducing the security of the password. Instead, make the password longer, e.g.



</dev/urandom dd ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/'


If you need the password to be memorable, that's a different problem. The best memorable passwords are passphrases.






share|improve this answer





















  • can this stdd in and out be removed please sol10 # dd if=/dev/urandom ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/' 9+0 records in 9+0 records out A9xk0r4MvMCY-Aa1 sol10 #
    – judi
    May 8 at 14:06











  • Thanks Much , this will eliminate the dd command output. dd if=/dev/urandom ibs=1 obs=1 count=9 2>/dev/null | uuencode -m - | sed '2!d; s/$/-Aa1/'
    – judi
    May 8 at 14:20















up vote
3
down vote













You can get cryptographic-quality random bytes from /dev/urandom. (This exists since Solaris 9. It also exists on Linux.) This includes unprintable characters, so you need to remove those. The following command extracts 10 random printable, non-space ASCII characters.



</dev/urandom tr -dc '!-~' | dd ibs=1 obs=1 count=10


I don't recommend using special characters in passwords. They don't make passwords more secure. What makes the security of a password is its entropy. A 10-character password has 10×log2(94) ≈ 65.5 bits of entropy. You can get the same amount of entropy from 9 arbitrary bytes and encode them as you wish, for example as hexadecimal.



</dev/urandom dd ibs=1 obs=1 count=9 | od -tx1 -An | tr -d ' '


Or as Base64, which is shorter.



</dev/urandom dd ibs=1 obs=1 count=9 | uuencode -m - | sed -n 2p


If there's some hard constraint that “passwords must contain at least one special character” (which is a questionable way to make passwords selected by average humans more secure, and it completely wrong for randomly generated passwords), then you can't simply use a random password, because there's a chance that it'll happen not to contain any character in a required class. If you reject passwords that don't meet the constraint, you're reducing the security of the password. Instead, make the password longer, e.g.



</dev/urandom dd ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/'


If you need the password to be memorable, that's a different problem. The best memorable passwords are passphrases.






share|improve this answer





















  • can this stdd in and out be removed please sol10 # dd if=/dev/urandom ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/' 9+0 records in 9+0 records out A9xk0r4MvMCY-Aa1 sol10 #
    – judi
    May 8 at 14:06











  • Thanks Much , this will eliminate the dd command output. dd if=/dev/urandom ibs=1 obs=1 count=9 2>/dev/null | uuencode -m - | sed '2!d; s/$/-Aa1/'
    – judi
    May 8 at 14:20













up vote
3
down vote










up vote
3
down vote









You can get cryptographic-quality random bytes from /dev/urandom. (This exists since Solaris 9. It also exists on Linux.) This includes unprintable characters, so you need to remove those. The following command extracts 10 random printable, non-space ASCII characters.



</dev/urandom tr -dc '!-~' | dd ibs=1 obs=1 count=10


I don't recommend using special characters in passwords. They don't make passwords more secure. What makes the security of a password is its entropy. A 10-character password has 10×log2(94) ≈ 65.5 bits of entropy. You can get the same amount of entropy from 9 arbitrary bytes and encode them as you wish, for example as hexadecimal.



</dev/urandom dd ibs=1 obs=1 count=9 | od -tx1 -An | tr -d ' '


Or as Base64, which is shorter.



</dev/urandom dd ibs=1 obs=1 count=9 | uuencode -m - | sed -n 2p


If there's some hard constraint that “passwords must contain at least one special character” (which is a questionable way to make passwords selected by average humans more secure, and it completely wrong for randomly generated passwords), then you can't simply use a random password, because there's a chance that it'll happen not to contain any character in a required class. If you reject passwords that don't meet the constraint, you're reducing the security of the password. Instead, make the password longer, e.g.



</dev/urandom dd ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/'


If you need the password to be memorable, that's a different problem. The best memorable passwords are passphrases.






share|improve this answer













You can get cryptographic-quality random bytes from /dev/urandom. (This exists since Solaris 9. It also exists on Linux.) This includes unprintable characters, so you need to remove those. The following command extracts 10 random printable, non-space ASCII characters.



</dev/urandom tr -dc '!-~' | dd ibs=1 obs=1 count=10


I don't recommend using special characters in passwords. They don't make passwords more secure. What makes the security of a password is its entropy. A 10-character password has 10×log2(94) ≈ 65.5 bits of entropy. You can get the same amount of entropy from 9 arbitrary bytes and encode them as you wish, for example as hexadecimal.



</dev/urandom dd ibs=1 obs=1 count=9 | od -tx1 -An | tr -d ' '


Or as Base64, which is shorter.



</dev/urandom dd ibs=1 obs=1 count=9 | uuencode -m - | sed -n 2p


If there's some hard constraint that “passwords must contain at least one special character” (which is a questionable way to make passwords selected by average humans more secure, and it completely wrong for randomly generated passwords), then you can't simply use a random password, because there's a chance that it'll happen not to contain any character in a required class. If you reject passwords that don't meet the constraint, you're reducing the security of the password. Instead, make the password longer, e.g.



</dev/urandom dd ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/'


If you need the password to be memorable, that's a different problem. The best memorable passwords are passphrases.







share|improve this answer













share|improve this answer



share|improve this answer











answered May 8 at 12:47









Gilles

503k1189951522




503k1189951522











  • can this stdd in and out be removed please sol10 # dd if=/dev/urandom ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/' 9+0 records in 9+0 records out A9xk0r4MvMCY-Aa1 sol10 #
    – judi
    May 8 at 14:06











  • Thanks Much , this will eliminate the dd command output. dd if=/dev/urandom ibs=1 obs=1 count=9 2>/dev/null | uuencode -m - | sed '2!d; s/$/-Aa1/'
    – judi
    May 8 at 14:20

















  • can this stdd in and out be removed please sol10 # dd if=/dev/urandom ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/' 9+0 records in 9+0 records out A9xk0r4MvMCY-Aa1 sol10 #
    – judi
    May 8 at 14:06











  • Thanks Much , this will eliminate the dd command output. dd if=/dev/urandom ibs=1 obs=1 count=9 2>/dev/null | uuencode -m - | sed '2!d; s/$/-Aa1/'
    – judi
    May 8 at 14:20
















can this stdd in and out be removed please sol10 # dd if=/dev/urandom ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/' 9+0 records in 9+0 records out A9xk0r4MvMCY-Aa1 sol10 #
– judi
May 8 at 14:06





can this stdd in and out be removed please sol10 # dd if=/dev/urandom ibs=1 obs=1 count=9 | uuencode -m - | sed '2!d; s/$/-Aa1/' 9+0 records in 9+0 records out A9xk0r4MvMCY-Aa1 sol10 #
– judi
May 8 at 14:06













Thanks Much , this will eliminate the dd command output. dd if=/dev/urandom ibs=1 obs=1 count=9 2>/dev/null | uuencode -m - | sed '2!d; s/$/-Aa1/'
– judi
May 8 at 14:20





Thanks Much , this will eliminate the dd command output. dd if=/dev/urandom ibs=1 obs=1 count=9 2>/dev/null | uuencode -m - | sed '2!d; s/$/-Aa1/'
– judi
May 8 at 14:20













up vote
-1
down vote













You have perl in Solaris, it helps:



perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10'


With special characters it will be:



perl -e 'print [0..9,a..z,A..Z,qw- _ / & ?]->[rand 67]for 0..10'





share|improve this answer























  • Thanks - but there is no special characters. sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' e9RKUJiss3 sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' zLdxvTqlJT sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' AiaiDubgye sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' lJxiV2iDwY sol10 #
    – judi
    May 8 at 12:01











  • You may add special characters in such way: perl -e 'print [a..z,A..Z,0..9,qw- _ / & ?]->[rand 67]for 0..10'
    – Sasha Golikov
    May 8 at 12:24







  • 1




    No, Perl's rand is not suitable to generate a password. This answer is insecure.
    – Gilles
    May 8 at 12:31














up vote
-1
down vote













You have perl in Solaris, it helps:



perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10'


With special characters it will be:



perl -e 'print [0..9,a..z,A..Z,qw- _ / & ?]->[rand 67]for 0..10'





share|improve this answer























  • Thanks - but there is no special characters. sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' e9RKUJiss3 sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' zLdxvTqlJT sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' AiaiDubgye sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' lJxiV2iDwY sol10 #
    – judi
    May 8 at 12:01











  • You may add special characters in such way: perl -e 'print [a..z,A..Z,0..9,qw- _ / & ?]->[rand 67]for 0..10'
    – Sasha Golikov
    May 8 at 12:24







  • 1




    No, Perl's rand is not suitable to generate a password. This answer is insecure.
    – Gilles
    May 8 at 12:31












up vote
-1
down vote










up vote
-1
down vote









You have perl in Solaris, it helps:



perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10'


With special characters it will be:



perl -e 'print [0..9,a..z,A..Z,qw- _ / & ?]->[rand 67]for 0..10'





share|improve this answer















You have perl in Solaris, it helps:



perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10'


With special characters it will be:



perl -e 'print [0..9,a..z,A..Z,qw- _ / & ?]->[rand 67]for 0..10'






share|improve this answer















share|improve this answer



share|improve this answer








edited May 8 at 12:38


























answered May 8 at 11:44









Sasha Golikov

1317




1317











  • Thanks - but there is no special characters. sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' e9RKUJiss3 sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' zLdxvTqlJT sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' AiaiDubgye sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' lJxiV2iDwY sol10 #
    – judi
    May 8 at 12:01











  • You may add special characters in such way: perl -e 'print [a..z,A..Z,0..9,qw- _ / & ?]->[rand 67]for 0..10'
    – Sasha Golikov
    May 8 at 12:24







  • 1




    No, Perl's rand is not suitable to generate a password. This answer is insecure.
    – Gilles
    May 8 at 12:31
















  • Thanks - but there is no special characters. sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' e9RKUJiss3 sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' zLdxvTqlJT sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' AiaiDubgye sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' lJxiV2iDwY sol10 #
    – judi
    May 8 at 12:01











  • You may add special characters in such way: perl -e 'print [a..z,A..Z,0..9,qw- _ / & ?]->[rand 67]for 0..10'
    – Sasha Golikov
    May 8 at 12:24







  • 1




    No, Perl's rand is not suitable to generate a password. This answer is insecure.
    – Gilles
    May 8 at 12:31















Thanks - but there is no special characters. sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' e9RKUJiss3 sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' zLdxvTqlJT sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' AiaiDubgye sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' lJxiV2iDwY sol10 #
– judi
May 8 at 12:01





Thanks - but there is no special characters. sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' e9RKUJiss3 sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' zLdxvTqlJT sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' AiaiDubgye sol10 # perl -e 'print[0..9,a..z,A..Z]->[rand 62]for 1..10' lJxiV2iDwY sol10 #
– judi
May 8 at 12:01













You may add special characters in such way: perl -e 'print [a..z,A..Z,0..9,qw- _ / & ?]->[rand 67]for 0..10'
– Sasha Golikov
May 8 at 12:24





You may add special characters in such way: perl -e 'print [a..z,A..Z,0..9,qw- _ / & ?]->[rand 67]for 0..10'
– Sasha Golikov
May 8 at 12:24





1




1




No, Perl's rand is not suitable to generate a password. This answer is insecure.
– Gilles
May 8 at 12:31




No, Perl's rand is not suitable to generate a password. This answer is insecure.
– Gilles
May 8 at 12:31












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442519%2fgenerate-random-password-with-special-characters-on-solaris%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay