-->

DEVOPSZONES

  • Recent blogs

    How to use PWGEN on Linux -- A command line random password generator

    How to use PWGEN  on Linux -- A command line random password generator


    This article will provide you with some hints on how to generate random password using shell.

    Add the Repository:


     yum install epel-release

    [root@dockerworkernode2 ~]# yum install epel-release
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: d36uatko69830t.cloudfront.net
     * extras: d36uatko69830t.cloudfront.net
     * updates: d36uatko69830t.cloudfront.net

    How to Install:

    DEBIAN/UBUNTU
    # apt-get install -y pwgen
    FEDORA
    # dnf install -y pwgen
    CENTOS /RHEL
    # yum install -y pwgen

    Examples:

    Let's start by generating bunch of passwords. If no options are used pwgen will simply generate 160 passwords with 8 characters each:

    Aenah2yo Phi1fie2 ojaidu5B AhN5on7b duC1fahC Aeth5Ruo jai0Lei7 joo2Ahho
    Jei1Xai7 mieYej8i HohFai9U Quohv5ee aichoh1A ahyaid1E ooph6Eif Be6bigo0
    phahvi0J seke8iaP Aemiev2l iW4Eep9U uSh4ie5h Auqu5shi ai9ooGae iefeec0E
    De0ohkie aelooNg1 haath2Th riez8Ume iejooQu5 mahPhi9g eiTh0tha duT5eeWa
    Naur9bah de2Hah1i qua6maeF ooCoh6Ja nie0OhFi jah9ooNg loochu0T aa9oit3U
    ui2Raij1 Eeri6ho4 aeB0Eaqu aephai5M aahaiK3E eephuc5A Aex7gife Eu4Cohth
    The8ub2a iX5Ech8f kae5AePu jo2Ohtoh Yah8thoh seC1aa3a Re4deiPh siv6Fuan
    hae1tohW ohtif3Ei Aiso9ieN ohth5Uno nee5Eepe Iexe8oon IeFuth9l Nae6mooy
    soofoo3N Fae9sah0 eGhooB5U iech9Ahp ahGoeb1o Oozooch6 ieg3Eewu me9Dee9g
    bee8aeL1 zoiYae0e deeNg6ae IeNg4ain AoGie8Ie zeF1ohko dee4eeYe Iec8iesa
    deiG7mo5 Pheishi8 Maipai3b AiShu4xu thaiSoo5 weibooZ5 os3Gooph dooRo7uP
    ohthua5A pee1APee teiF3kai Ahsai3yo OoJij3hu tae4Deej xe7zee8K aiVaib8y
    shaeg2Ai Nah2ohse Oochoo9t ievu1EiG ohy8Aiz0 ouWei8ae IaC8kaxo ahwaec5O
    ci3joaPh ho1EiThe Uquahqu2 ier6Aeph cheKue3f Taeb4EZo ahMao5Ji ahHoh7Ei
    oi1IeNgu daeNe5ju uxo7Ke4y oh8Eexi5 aiS1aiv4 iu7oaL0C Misheet9 UeSh2oy8
    queeC1Ae ha4cieBi aeS5geoW juHah4ie Yaegik1o Bath6shu aiGaip2s iJ0iX0qu
    OWung1ve oTho2Kie eo1Aixae pat1Kah9 ba7Quaef aeWohTh9 Aengoko6 be7Eix2b
    shagaiN7 aishu4Th tohnaM1e liy5Fei9 Yaezoo7u Aecohg7l eeQu3aer Ahp1dahL
    OPhaif8y ieciR7oo Xaecheg4 Aiph6ooK AiJiehe9 Aen9quae euk5daiW eiRaiSo5
    doo0Jong Chagh6Va Ahphee9W Eeshoh4B tei8aoB7 aimuon9D Eew9vaek coG5oiph

    pwgen

    Generate 16 Character Password:


    [root@dockerworkernode2 ~]# pwgen -y 16
    wie(doo2eiF3eGhu Die2foSh.iekei!w yau{BieX(u6Eeng9 eQu9wah\goam7eze
    ohTi=uxoo^xeiy8a so2Chah0AN[ooYoo eg9xei5cu6il'aCh ohb0ku,Mae9TheSu
    ga`ew4aiteiKi|No iiph;i7shoofuN=a vepiPi`go'o1wai7 xox8iefeing`ai4C
    Toog&eY'ahgith5o gim<ei7Aigoozoo7 Inga9um]oohiP8xe weeshin4PhieWow/
    AiCheo8chee2Nai` Iere)iw7oogh4fei quaziCh0heng"e5a Thoo8ahv3och[u2r
    uwahr2ahnuu=y3Ut Jui-k7Aime<bahl6 ZeethohgaiP\em8u noT2iu1Teel*ou2R
    Rip4eigei=r-ei8A uPae5Rooph/egh*o eeyoo6lahkei_Sae yei%z9ohfuaYaege
    zohz'e6oru0EeYel othaish6wo'i8ohJ vue8Zavaezau:ma] queu|Gh9iadeiw7g
    iey9eiM7phohyi(S zo2Co3ra)u1aewah Ceri7nijee?shaex aijais)ait7Mee7e
    pai9voh5Eeng[ie3 taeNieth3coaj~o7 IeTh8eiV~a9ieSh] Wo\fie)ch0Oong1A
    Eithee;g7tahghiu eeh&o6fien9au6Ai Aerae4geiNieR*oh Ie8eeja!Ngo1Aech
    achohY*aePh2raej zifahL3ue?F3sief us1ib)eif0Eej?uo cae+ph7IWaivequ&
    biqu5vu&Nahriuvi pheejie%C5pe5iec aom=eiveiG8hoh4a chaeh8tae_Fiecoo
    paxaDeeShoh:zie6 ID?ea8Ro*v3zie_f UY'aishi5nei6hai Mi1aes[ohzeech~e
    fiej1Fie=vai#s2t oJ+ee2eu"ghing6E soh9eesh}e)W?aef yi5neeSh8goh+j1E
    ue1ao:zeelieShai aiBeigei=vi]Ch8e ohC.o9eeNgay6yi0 Nie{zohQu7ooz9ye
    cahyeiv5Waish&ai oisu/vaeQuongue5 uNgei,th6heechae loh]ph4Ohc;aenge
    Oowung%a3eiW5zei gohX.ai2hoaWohki Eisaeng7iChoh_m8 Waic8Sei}N9aeji8
    thae1eep4ni2Do;i nae7Aejie(ng%aeB Isoh3wai>dis4aiS oosh=iemoof/a7Ie
    oop~ij_aeV0uemie ooHok1eu:j7haiWe cookoom_ai5AiB_a puW8aec8lai\n5oe
    [root@dockerworkernode2 ~]#

    Produce a single secure 16 characters long random password:

    [root@dockerworkernode2 ~]# pwgen -s 16 -1
    y0bTClJo75JraAmr
    [root@dockerworkernode2 ~]#

    Lets create password for 10 Users:



    1. create a file:


    [root@dockerworkernode2 ~]# cat users.txt
    ram
    shyam
    gita
    hari
    dhari
    manas
    ramesh
    suresh
    harish
    girish
    [root@dockerworkernode2 ~]#

    2. Write a simple script to align these password to the user and print them:

    [root@dockerworkernode2 ~]# for i in $( cat users.txt ); do pwgen -s -1 16 1 | sed "s/^/$i /"; done
    ram R0bcSJ33wGeVEEzl
    shyam 8pF1zl3aK4UmssAA
    gita LsRIfc7uvmjuroIM
    hari fuRNZcz3oyxWUw0f
    dhari il9kukG3KrAHfomi
    manas 28la3HaBO4uzZj1E
    ramesh jbjO3a9G2OalQTT4
    suresh nCM8QUG5YdrcC0rB
    harish a4OZKgdPiVqtfYtu
    girish o3pqLtk8ndesQMa5
    [root@dockerworkernode2 ~]#

    pwgen script


    By default the pwgen attempts to generate passwords which should be easier to remember. To get a completely random strings combine pwgen with -s secure option:

    [root@dockerworkernode2 ~]# pwgen -s
    iu0f5aeT 06bpU7Ef aen29ySH l4WGUhmG f0oMurbx 6loiyHea X9JUFLQZ fid5TU3v
    7cq5Rlgg 5Yp2SO6r GA6V3GiT ziuRSXo8 CO30u2qv M95GObXk PjthSB64 O0oRBASK
    3nIUd1ou RKlsaj4w UQJTT04Y lS6nrBqa 1lI31jZi wH5y7GJ9 xGVHIu9O 8CQp1F8S
    l6XTwNF4 FqN8nvpx A9LkVJfD l5KHcVPl 6edZRjyA y0eLcXci C4rqKYXL R6xhkwlm
    4oSB3R4y 6tKi9cif 2DBkNiQa MpAr7rsK YVbLg1YB 44VJAkGc hSAs4IOk U9J4tlJc
    eBcbp051 2i8nxChg 7JfhAwSe SJDA2t2H ELVt11cr K56Hifrk FHr2GZ5n X2k375B4
    8Gm4byhv mbS3lvdZ n3OqI9mK a6XW2VNc Mg9x6dLc 1DYG5cNY yTM8bdzA y5NzLkHq
    8eoyEqFC Mzxm1oWk rvP9uMzh xpE3tTH8 1vtVrSfA 6G1IeXGC YuQf6qMt jKk8J07K
    wfxuEu6a vPIhUU17 1kzoQPij 3tkgw5JH 4sILlj4p l2zYzlgH ecYr73qz DBhJ6lcN
    T55BuZZN NifNq03m K2W4f79Z DPCGz0og 8TU3zeVT F4QtZpSu A9UcP5X1 H2g4TkWf
    iEmcV9Gw H31C0Nor dvIV7gUy 5xLkoZfP BMVcBM4h vK3FXkX8 0mlcIg9p KFqQ8DI8
    mHQsRfK5 y0EJiHUH 3RUAblJ8 h8wpIMuT s8ASzaNp YeZPAHV2 DL6C3C73 LxJb6WFI
    mMkHY2Ej vARG5N83 6ISjdED0 r2cRYnSb j9mDGW2L aoNsn2P4 q2LKb6Sw 8JviNlvG
    qNn6bxFW rZrVIW6t rk1EhGJH G9RaNl11 cTv8DsKb 8cJSxXUK 9YeCXm3N mXNeTc2T
    jAdjR4dy GN3hsRsk sM6fdchi LPg4hXLy 5SXHf0gB SvFjh5Q3 W4edG9zt WC7n8N0E
    pdK2bso0 TrmCgy23 7K5TCuvz vJqlSpr7 1tsIsB4F Bq5KEEIR 4kTpwDqB 1q1V0EnR
    44YGlPnu 35WA1AnP tb4J41mn 501isTwn TP7ODaPX oriR2KEb wV6Ouw3T 3Eeu7WJc
    BG5ZdAeb Q4gUqfRM v2AIWccG iA7xyDus NH3SmCD3 4zw31JIV i5dTs8cX Cjiw3LRb
    Nu3LDpoa 2Wd81EHy DGCN8Ijw 03z8Jpjc 1UxyMqTp HKSh2oCN FBO7BoxD H3vCTUiD
    uZlY9llk 6LvKrYGZ zWW7YwZ6 9djahSzs XF4pMoD8 yMe8hu85 arZ0o0MG akfM7uR9
    [root@dockerworkernode2 ~]#


    Include at least one capital letter in the password

    [root@dockerworkernode2 ~]# pwgen -c
    Sohsh7th oxoh1Eoc ao3eiCoh ye2Aequ8 fooWee1l Ito0kaif boh7Eib3 Ago3feGu
    aiP0loaH ha1noh6C Oom4ohgh Queeh5va Azei5eku phu9Te8d ohSei0ej gohQu9fa
    yohCoh5a tah8Paye Vaerah6a jo7itoaP aiz1Gop9 fi9theRi Eirie9ia zoo4GeeC
    ain5uCh4 Uecokoi1 ahk6Ohgh Oog0sait Mohgoh8O ceedahL1 Au8em9oj gah5Udie
    uaNgox2u rah3Ufae aBo1Aid3 Taivusi3 viePh4oo aj4JaeMo Theida9o uuGah8ae
    ei7Ep9sh ioK1dav5 ueTae4ce phohNg6t Ohzeiko6 aMahc3Hu Keo9cooy iYaihie2
    eiNei6uo Ru0thea9 yah1Ook2 eihahGh5 igh7Oove aeNgoi1Y ieteeV5o chufuZ8O
    shai9Sed Wai9euye Aig1eiqu depu3ooX ohNee8xo eyah3ahG Pun0ahg9 ethio4Oo
    eiN1daes aevi7Mop OoGhe8ot jaiVooz5 Aed5uolo chuCoh5c Pab1ioph boh6Zu7y
    Da6oht7i TheiXei1 ox7MuPhe Jie3uah7 viev2Ov0 aeWoh1ha amie2Yi2 Ez1aigoo
    eoJ8oo7I eeChi2Ko Thoxie5a Rai5joth tah3DuBu Esoo2eeS aiw2Iedi Loa2chie
    xunohQu5 loo2xooB aX8reeQu Shiphiy6 ea2zeiNu Oosheim9 ohngah7I rieL3Vah
    oYumoh9v Loo1doh4 bohhoH6c oowi4Ahb koofoo3E Liehaeb6 ooquah3O eVu4koof
    Gieth3sh Zuu3eeTh uu1Theix AiPh7hia eikoTei5 ain0eiTe Aeve4ate Ohye8Shi
    icaago0E chohph3T Pushe0xo eiPey7ee ohpohl2C Gee2EeRa EMou6Nee EF2Vaish
    goo9eiCh noivoo7T ia8Ahj1i pheLing6 shi3MahF ohQu2eeh aiBae7iY aeJ4eoch
    Yeekae8o ieD2moof Ma4eezij iQuai3ah aiZou9tu cac1uv5N uRee4eej laeNgee0
    eiyeoPh4 Eida9noN Eew4AYe0 shoh3Fui Dootei6y Ahngoi3e Eegh2joh Oxahv8yi
    it6AC1Te ohD5aifa Chae3aiL Ti2queiP Ceimi9xe UX6aep0b eis8soeR daGhi6to
    Woht1jiy wat4eePh eigie3Ee iepho8Ee ahCah8ph Shix2xoo hei0aoCh Mah7chah
    [root@dockerworkernode2 ~]#



    Don't include capital letters in the password

    [root@dockerworkernode2 ~]# pwgen -A
    ooghohd2 xee2nuph ja4shi2e hoo1uuyo io2ohchi oox0aef6 ii4eib3e isee9cai
    ciyiet8e een8laim axead7oh ci5fooku eikiij4u neeh9hei oomah4iy eef1uo8d
    ahh8aile eengo1oh oongah3i shei4nie daisith7 ou6oheek jaequoh7 eirah3pu
    ieshaib8 aeh1chae go9eib4h awong5qu oth6phou nahgae4o oozi8goh laireiz5
    ok5quaeg aej0xohl phoo7dae ev5rei5i ci8ohgho sha1bahv uo4sooqu eiv8eeth
    aey0ighe lahp7xoo ahj0ahng nie3dish geija7iu uifah7li eech2dah ohgh5co4
    nohpha4a ef3puh0i ihaht0ie ieh6pahl eethue2h ahh9oogh osh0phee quai7ei9
    quaich5k iixoh1ch sheite5x ohqua2oh aiqu5ogo jumeik4a ohk3taiv cai8zigh
    zoovu3oc xie6fe1w od4ahm5e eireita6 koo6rail bahv0eis wahp8aic thah0xie
    fie9vohv yoog3tah eigei7az thaliel4 phiek7sh baesh0ue jij6ohph eichiem7
    zid6upee lahchah8 eol4thix edohl2ah eesh2vai uc1oo2ph ahsia5th phub7ilu
    vebe9aik neegup6b haem8equ nooji7ie nu5kahno noh1boo1 zaig5ain boohaih0
    fei0moow fieneo1i ce5gieng kahth3vi fi2phai7 zohze9oo ia5chohx tae6aes2
    xibeelu1 feik6eel nieyod9l ohb2yahv kohce2ai topoo8ai ce6eezei gu1ahc5u
    fea6aih4 ee2oomoo rohdei1l lo6ahwie cheighi1 shai0ohy au8ooyah aep8oisa
    ea5oophi quahx9ou cieba4uf bahcha9u aew2aib9 ino3ez9f eechae2j chox3aht
    uoxeem0p ahj3shie iep1acei thieyah3 ewooch3u cha9sexe ook5aewo cu3mohhe
    xaith6le aihoo1ai eweixio0 ciej8cah auph8wae uyaec5mo uuwoo8ai eir9phai
    aetheeg8 phai7paa oi2ozohs cai5oa0e iak3eeng aig1yohz die4woob oichae7c
    eemah6yu feith0ch eib0aini la1oop0e sae9ief6 iep9ohwo eizaek3i ohn4zaev
    [root@dockerworkernode2 ~]#

    Include at least one special symbol in the password


    [root@dockerworkernode2 ~]# pwgen -y
    Ood)eep7 Aex2cae/ choo$L6e ne'P8kai Sae&m3ia Moo*pae7 oa6jo*aL aith>uL5
    uqu7AGo* ahv2Aes> auMa~a9n chee]W9a Aet3ta=p eph!aeJ6 uN[ah5lo fa\uC0fa
    zaH(a1aF vi4Aer=o ee4Vit}u Boh1ohk, Eigh9Su` ri8Xei$K AiX2oom[ coiT@oo1
    eo&Xoh4E ahZ|ae8u iz/ei2Io Ru_p9oon agh"ae3J ca5Chi-B Ou4ieg'u Ahl:ea4a
    ae0EPh$i Le3uawe\ eloh&F9h aiw*ai6E xee/M3Oo ai4Wie/s ahgei!Z1 Ya1jaik<
    Yai:th2I gi1Oip/a Cah3aiS) eeC7kah" Xai$w6ga shux"oX6 ta2oV;ei Ohb=oh3i
    fei_ch8X Aig9mi-f zoh.Lei5 eiko|Ch9 il)ei0Ie Phee$b8v ti-eNg3f zo3ria%P
    iu1Se%n/ Eu"thoo7 the)h2Ah Xe(p3Ahb Ahch"ee0 soh|L1ae Oon?o7fa sah;Gu3E
    kio*Gu1a aeW(ae8O woPh]ie8 Aa%s0hee xi<p8eiM ra6Oto(a Ca5muuB? ahF/ee0I
    IaH,ee9t jeiC&ei9 Sho5tho' ec6mui?C AiV+ee5W aeF`u2Fi Fahai_v1 wee(Ng5o
    Lai]S6ai Ge8ieTh! Ieh<a4oo Joh@key7 au~Laem4 quo3Bix@ Gae3Uob& ob0Faej~
    Ogh!i0Ei bie$g9Di Zai/l1Oo rohM;e1h Ung'ang0 Quoo=T2f jee4ji:H Ies_i4ae
    Ahs9Ao"n oon)u3iF iew1Aqu- Ox=ei7ah uweeP"i5 aeTho?i3 Eifae~g2 ohM6ahh&
    Ee>v9qua Oi3Ahth^ eiCe5zi* Pa(Ngae2 sho"X9ye uM(ai7af ouK@ieb4 Haey<oo4
    ahS_oix3 Eif7sai% Jie#Ph2A jah]w2Ie juV=o1Mo Biep8ap` eiT:ah6v aes*eV8e
    Wie@x4Ch gith6Uy? Yoo(z0Ch yai1EiX' cu5AeK(e Uz{e4ta5 ogh3Wiu# moh>N1xe
    ahP{ei7l Foop/i1r mu>L1Gee lae6cu$R Sai-k6Ee weeF$uv9 ShaRe`p5 vo6Aepo'
    angie|K0 The/i7nu Pee{Gh0b phiv,i0E roo<B2iu xoo?w2IZ Pai[N4li eC3Rei&x
    Xiu^w5ia ieM0vo-F Ool9ko$u phe+S7re Naht7ec{ Rux4aip. quoh/J9e Pae6roh<
    eph4aeT$ Die1eiR{ Roh=v9te quei7Ei@ hah2po:Z hai:We9s ut6To&qu Foo?b6ib
    [root@dockerworkernode2 ~]#


    No comments