{"id":3486,"date":"2020-08-04T13:24:46","date_gmt":"2020-08-04T04:24:46","guid":{"rendered":"\/blog\/?p=3486"},"modified":"2023-09-21T09:26:40","modified_gmt":"2023-09-21T00:26:40","slug":"linux-%ec%82%ac%ec%9a%a9%ec%9e%90-%eb%b9%84%eb%b0%80%eb%b2%88%ed%98%b8-%ec%9e%90%eb%8f%99%eb%b3%80%ea%b2%bd-%ec%8a%a4%ed%81%ac%eb%a6%bd%ed%8a%b8","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=3486","title":{"rendered":"[Linux] \uc0ac\uc6a9\uc790 \ube44\ubc00\ubc88\ud638 \uc790\ub3d9\ubcc0\uacbd \uc2a4\ud06c\ub9bd\ud2b8"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n###########################################################################\n#\n# Linux \uacc4\uc815\uc758 \ud328\uc2a4\uc6cc\ub4dc\ub97c \ub79c\ub364\ud558\uac8c \ubcc0\uacbd\ud558\uace0 \ub2f9\uc0ac\uc790\uc5d0\uac8c \uba54\uc77c\uc744 \ubcf4\ub0b8\ub2e4.\n#\n# \ud544\uc694\ud55c \ud328\ud0a4\uc9c0 \uc124\uce58: yum -y install pwgen ImageMagick mailx\n#\n# $ crontab -e (\ub9e4\uc6d4 1\uc77c 00:10\uc5d0 \uc2e4\ud589)\n# 10 0 1 * * \/etc\/scripts\/pw_changer.sh\n#\n##########################################################################\nCURRENT_TIME=$(date \"+%Y-%m-%d_%H:%M:%S\")\nCURRENT_DATE=$(date \"+%Y-%m-%d\")\nCURRENT_PATH=$(pwd)\nSENDER_MAIL=\"pwchanger@esvali.com\"\nMAIL_DOMAIN=\"esvali.com\"\nLOG_FILE=\"\/var\/log\/esvali_pw_changer.log\"\nPNG_FILENAME=\"\/tmp\/${CURRENT_DATE}.png\"\nTMP_FILENAME1=\"\/tmp\/__tmp_file1__.txt\"\nTMP_FILENAME2=\"\/tmp\/__tmp_file2__.txt\"\n\n###########################################################################\n# \ud30c\uc77c\uc758 \uc874\uc7ac\uc640 \uc2e4\ud589\uac00\ub2a5\uc5ec\ubd80 \uac80\uc0ac\n##########################################################################\nfunction check_file() {\n  if [ ! -x $1 ]\n  then\n    echo \"$1 not found.\"\n    exit 1\n  fi\n}\n\n###########################################################################\n# \uc720\ud2f8\ub9ac\ud2f0 \uccb4\ud06c\n##########################################################################\nfunction prepare_run() {\n  check_file \/usr\/bin\/pwgen\n  check_file \/usr\/bin\/convert\n  check_file \/usr\/bin\/mail\n}\n\n###########################################################################\n# \ubb38\uc790\uc5f4\uc744 \uc774\ubbf8\uc9c0\ub85c \ubcc0\ud658\n# text2png &lt;text>\n##########################################################################\nfunction text2png() {\n  if [ -f ${PNG_FILENAME} ]\n  then\n    rm -f ${PNG_FILENAME}\n  fi\n\n  # \uac00\uc6a9 \ud3f0\ud2b8 \uc54c\uc544\ubcf4\uae30: convert -list font\n  \/usr\/bin\/convert -size 640x100 xc:\"rgba(0,0,0,0)\" -font \"FreeMono-Bold\" -pointsize 64 -fill blue -annotate +64+64  \"$1\" ${PNG_FILENAME}\n}\n\n###########################################################################\n# \uc554\ud638\ub97c \ubcc0\uacbd\ud558\uace0 \uba54\uc77c\ub85c \ubcf4\ub0b8\ub2e4.\n# change_pw &lt;os id> &lt;email>\n##########################################################################\nfunction change_pw() {\n  # \uc2e0\uaddc \ube44\ubc00\ubc88\ud638\ub97c \uc0dd\uc131\ud558\uc5ec $NEW_PASSWD\uc5d0 \ub123\ub294\ub2e4.\n  pwgen -CcysnB 10 1 > ${TMP_FILENAME1}\n  if [ $? != 0 ]\n  then\n    echo \"Failed to pwgen.\"\n    exit 1\n  fi\n  NEW_PASSWD=$(cat ${TMP_FILENAME1})\n  text2png ${NEW_PASSWD}\n\n  # \uba54\uc77c\uc744 \ubcf4\ub0b8\ub2e4.\n  echo \"Password changed time: ${CURRENT_TIME}, Look at the attachment.\" > ${TMP_FILENAME2}\n  mail -a ${PNG_FILENAME} -r ${SENDER_MAIL} -s \"$1@${MAIL_DOMAIN} password changed. (${CURRENT_DATE})\" $2 &lt; ${TMP_FILENAME2}\n  if [ $? != 0 ]\n  then\n    echo \"Failed to mail.\"\n    exit 1\n  fi\n\n  # \ube44\ubc00\ubc88\ud638\ub97c \ubcc0\uacbd\ud55c\ub2e4.\n  echo \"${NEW_PASSWD}\" | passwd --stdin $1\n\n  # \ub85c\uadf8\ub97c \uae30\ub85d\ud55c\ub2e4.\n  #echo ${CURRENT_TIME} \\\"$1\\\" \\\"$2\\\" \\\"${NEW_PASSWD}\\\" >> ${LOG_FILE}\n  echo ${CURRENT_TIME} \\\"$1\\\" \\\"$2\\\" >> ${LOG_FILE}\n\n  # \uc784\uc2dc\ud30c\uc77c \uc0ad\uc81c\n  rm -f ${TMP_FILENAME1} ${TMP_FILENAME2} ${PNG_FILENAME}\n}\n\nprepare_run\nchange_pw \"user1\"   \"user1@naver.com\"\nchange_pw \"user2\"   \"user2@daum.net\"<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[39],"tags":[],"class_list":["post-3486","post","type-post","status-publish","format-standard","hentry","category-os_linux_unix_macos"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3486"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3486\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}