{"id":594,"date":"2009-11-12T02:56:48","date_gmt":"2009-11-12T07:56:48","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/?p=594"},"modified":"2009-11-12T02:56:48","modified_gmt":"2009-11-12T07:56:48","slug":"bash-script-to-email-random-passwords-to-users","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/","title":{"rendered":"Bash script to email random passwords to users"},"content":{"rendered":"<p>Here is a bash script to randomly generate a password and send it to a user&#8217;s email address. It will also write the user&#8217;s email address and password to a csv file for importing into your MySQL database via <a title=\"http:\/\/www.phpmyadmin.net\" href=\"http:\/\/www.phpmyadmin.net\/\">phpMyAdmin<\/a>.<\/p>\n<p>The script assume you have a text file (emails.txt) in your home directory with a list of email addresses to start with. You need never see the password if you don&#8217;t want to.<\/p>\n<p>shamelessly pulled from http:\/\/www.altfire.com\/main\/news\/index.php?news_id=371<\/p>\n<p>#! \/bin\/bash<\/p>\n<p># characters allowed in our passwords<br \/>\ncharspool=(&#8216;a&#8217; &#8216;b&#8217; &#8216;c&#8217; &#8216;d&#8217; &#8216;e&#8217; &#8216;f&#8217; &#8216;g&#8217; &#8216;h&#8217; &#8216;i&#8217; &#8216;j&#8217; &#8216;k&#8217; &#8216;l&#8217; &#8216;m&#8217; &#8216;n&#8217; &#8216;o&#8217; &#8216;p&#8217;<br \/>\n&#8216;q&#8217; &#8216;r&#8217; &#8216;s&#8217; &#8216;t&#8217; &#8216;u&#8217; &#8216;v&#8217; &#8216;w&#8217; &#8216;x&#8217; &#8216;y&#8217; &#8216;z&#8217; &#8216;0&#8217; &#8216;1&#8217; &#8216;2&#8217; &#8216;3&#8217; &#8216;4&#8217; &#8216;5&#8217; &#8216;6&#8217; &#8216;7&#8217;<br \/>\n&#8216;8&#8217; &#8216;9&#8217; &#8216;0&#8217; &#8216;A&#8217; &#8216;B&#8217; &#8216;C&#8217; &#8216;D&#8217; &#8216;E&#8217; &#8216;F&#8217; &#8216;G&#8217; &#8216;H&#8217; &#8216;I&#8217; &#8216;J&#8217; &#8216;K&#8217; &#8216;L&#8217; &#8216;M&#8217; &#8216;N&#8217; &#8216;O&#8217;<br \/>\n&#8216;P&#8217; &#8216;Q&#8217; &#8216;R&#8217; &#8216;S&#8217; &#8216;T&#8217; &#8216;U&#8217; &#8216;V&#8217; &#8216;W&#8217; &#8216;X&#8217; &#8216;Y&#8217; &#8216;Z&#8217;);<\/p>\n<p>len=$<\/p>\n<p>if [ $# -lt 1 ]; then<br \/>\nnum=6;<br \/>\nelse<br \/>\nnum=;<br \/>\nfi<\/p>\n<p>while read line<\/p>\n<p>do<br \/>\nfor c in $(seq $num); do<br \/>\npass=&#8221;$pass$&#8221;<br \/>\ndone<\/p>\n<p># output the to the csv file<br \/>\n# modify path to YOUR home directory<br \/>\necho -e &#8220;$line,$pass&#8221; &gt;&gt; \/home\/username\/passwords.csv<\/p>\n<p># email subject<br \/>\nSUBJECT=&#8221;Your Login Details&#8221;<br \/>\n# Email To ?<br \/>\nEMAIL=$line<br \/>\n# Email text\/message<br \/>\nEMAILMESSAGE=&#8221;\/tmp\/emailmessage.txt&#8221;<\/p>\n<p>echo &#8220;You can login to whatever using the following details:&#8221;&gt;&gt;$EMAILMESSAGE<br \/>\necho &#8220;&#8221;&gt;&gt;$EMAILMESSAGE<br \/>\necho &#8220;Email Address = $line&#8221;&gt;&gt;$EMAILMESSAGE<br \/>\necho &#8220;Password = $pass&#8221;&gt;&gt;$EMAILMESSAGE<br \/>\necho &#8220;&#8221;&gt;&gt;$EMAILMESSAGE<br \/>\necho &#8220;&#8221;&gt;&gt;$EMAILMESSAGE<br \/>\necho &#8220;&#8221;&gt;&gt;$EMAILMESSAGE<br \/>\necho &#8220;Signature or URL or whatever&#8221;&gt;&gt;$EMAILMESSAGE<\/p>\n<p># send email using \/bin\/mail<br \/>\n#change sending email address to your own!<br \/>\n\/usr\/bin\/mail -s &#8220;$SUBJECT&#8221; &#8220;$EMAIL&#8221; &#8212; -f username@domain.com&lt; $EMAILMESSAGE<\/p>\n<p># reset password to go again<br \/>\npass=&#8221;&#8221;<\/p>\n<p># input file &#8211; modify path to YOUR home directory<br \/>\ndone &lt;\/home\/username\/emails.txt<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is a bash script to randomly generate a password and send it to a user&#8217;s email address. It will also write the user&#8217;s email address and password to a csv file for importing into your MySQL database via phpMyAdmin. The script assume you have a text file (emails.txt) in your home directory with a&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-594","post","type-post","status-publish","format-standard","hentry","category-info"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Bash script to email random passwords to users - Linux Shtuff<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bash script to email random passwords to users - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"Here is a bash script to randomly generate a password and send it to a user&#8217;s email address. It will also write the user&#8217;s email address and password to a csv file for importing into your MySQL database via phpMyAdmin. The script assume you have a text file (emails.txt) in your home directory with a... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2009-11-12T07:56:48+00:00\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/bash-script-to-email-random-passwords-to-users\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/bash-script-to-email-random-passwords-to-users\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"Bash script to email random passwords to users\",\"datePublished\":\"2009-11-12T07:56:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/bash-script-to-email-random-passwords-to-users\\\/\"},\"wordCount\":315,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"articleSection\":[\"General Info\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/bash-script-to-email-random-passwords-to-users\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/bash-script-to-email-random-passwords-to-users\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/bash-script-to-email-random-passwords-to-users\\\/\",\"name\":\"Bash script to email random passwords to users - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"datePublished\":\"2009-11-12T07:56:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/bash-script-to-email-random-passwords-to-users\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/bash-script-to-email-random-passwords-to-users\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/bash-script-to-email-random-passwords-to-users\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bash script to email random passwords to users\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bash script to email random passwords to users - Linux Shtuff","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/","og_locale":"en_US","og_type":"article","og_title":"Bash script to email random passwords to users - Linux Shtuff","og_description":"Here is a bash script to randomly generate a password and send it to a user&#8217;s email address. It will also write the user&#8217;s email address and password to a csv file for importing into your MySQL database via phpMyAdmin. The script assume you have a text file (emails.txt) in your home directory with a... Read More","og_url":"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2009-11-12T07:56:48+00:00","author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"Bash script to email random passwords to users","datePublished":"2009-11-12T07:56:48+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/"},"wordCount":315,"commentCount":0,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"articleSection":["General Info"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/","url":"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/","name":"Bash script to email random passwords to users - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"datePublished":"2009-11-12T07:56:48+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/bash-script-to-email-random-passwords-to-users\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"Bash script to email random passwords to users"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=594"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/594\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}