{"id":877,"date":"2023-11-28T18:44:00","date_gmt":"2023-11-28T09:44:00","guid":{"rendered":"https:\/\/roroing.net\/?p=877"},"modified":"2023-11-28T18:44:00","modified_gmt":"2023-11-28T09:44:00","slug":"sshpass%e3%81%a0%e3%81%a8for%e6%96%87%e3%81%8c%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e3%81%8b%e3%82%89%e5%af%be%e5%87%a6%e3%81%97%e3%81%9f","status":"publish","type":"post","link":"https:\/\/roroing.net\/?p=877","title":{"rendered":"sshpass\u3060\u3068for\u6587\u304c\u3067\u304d\u306a\u3044\u304b\u3089\u5bfe\u51e6\u3057\u305f"},"content":{"rendered":"\n<p><strong> \u76ee\u7684<\/strong><br>\u6570\u591a\u306eIP\u304c\u3042\u308a\u8907\u6570\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u5019\u88dc\u306e\u4e2d\u3067\u3001\u3069\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u304cssh\u63a5\u7d9a\u3067\u304d\u308b\u304b\u3092\u77e5\u308a\u305f\u3044<br><br><strong>\u554f\u984c\u70b9<\/strong><br>sshpass\u30b3\u30de\u30f3\u30c9\u3067 for\u6587\u3092\u56de\u3059\u3068\u306a\u305c\u304b\u4e00\u56de\u306e\u51e6\u7406\u3067\u7d42\u308f\u308b<br><br><strong>\u89e3\u6c7a\u65b9\u6cd5<\/strong><br><code>ssh<\/code>\u00a0\u30b3\u30de\u30f3\u30c9\u306b\u00a0<code>-n<\/code>\u00a0\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3066\u89e3\u6c7a\u3057\u305f\u3002<br><br>\u53c2\u8003<br><a href=\"https:\/\/tech.kurojica.com\/archives\/36145\/\">https:\/\/tech.kurojica.com\/archives\/36145\/<\/a><\/p>\n\n\n\n<p>\u30b3\u30fc\u30c9\u4f8b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/sh\n\nsuccess_log=\"success.log\"\nfailure_log=\"failure.log\"\npasswords=('password1' 'password2' 'password3')\n\n# \u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3092\u521d\u671f\u5316\n> $success_log\n> $failure_log\n\nwhile read -r ip_address; do\n    echo \"Attempting login to $ip_address...\"\n\n    success=false\n\n    # 3\u3064\u306e\u7570\u306a\u308b\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a66\u884c\n    for password in \"${passwords&#91;@]}\"; do\n        sshpass -p \"$password\" ssh -o StrictHostKeyChecking=no -p 32122 -n user@$ip_address \"echo 'SSH connection successful!'\"\n        \n        # \u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u884c\u7d50\u679c\u306b\u57fa\u3065\u3044\u3066\u30ed\u30b0\u3092\u5206\u3051\u308b\n        if &#91; $? -eq 0 ]; then\n            success=true\n            echo \"Success: $ip_address (Password: $password)\" >> $success_log\n            break  # \u30ed\u30b0\u30a4\u30f3\u6210\u529f\u3057\u305f\u3089\u30eb\u30fc\u30d7\u3092\u629c\u3051\u308b\n        fi\n    done\n\n    # \u30d1\u30b9\u30ef\u30fc\u30c9\u8a66\u884c\u304c\u3059\u3079\u3066\u5931\u6557\u3057\u305f\u5834\u5408\n    if &#91; \"$success\" = false ]; then\n        echo \"Failure: $ip_address (All Passwords Failed)\" >> $failure_log\n    fi\n\ndone &lt; iplist.txt\n\necho \"Script execution completed.\"\n\n\n<strong>\u7c21\u5358\u306a\u89e3\u8aac<\/strong>\npasswords\u306b\u5224\u5225\u3057\u305f\u3044\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\n\u305d\u306e\u7d50\u679c\u306f\u4ee5\u4e0b\u306b\u5410\u304d\u51fa\u3055\u308c\u307e\u3059\u3002\nsuccess_log=\"success.log\"\r\nfailure_log=\"failure.log\"\n\nSuccess: xxx.xxx.xxx.xxx (Password: password1)\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u7684\u6570\u591a\u306eIP\u304c\u3042\u308a\u8907\u6570\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u5019\u88dc\u306e\u4e2d\u3067\u3001\u3069\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u304cssh\u63a5\u7d9a\u3067\u304d\u308b\u304b\u3092\u77e5\u308a\u305f\u3044 \u554f\u984c\u70b9sshpass\u30b3\u30de\u30f3\u30c9\u3067 for\u6587\u3092\u56de\u3059\u3068\u306a\u305c\u304b\u4e00\u56de\u306e\u51e6\u7406\u3067\u7d42\u308f\u308b \u89e3\u6c7a\u65b9\u6cd5ssh\u00a0\u30b3\u30de\u30f3\u30c9\u306b\u00a0-n\u00a0\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057 <a href=\"https:\/\/roroing.net\/?p=877\" class=\"more-link\">...<span class=\"screen-reader-text\"> \"sshpass\u3060\u3068for\u6587\u304c\u3067\u304d\u306a\u3044\u304b\u3089\u5bfe\u51e6\u3057\u305f\"<\/span> \u3092\u7d9a\u3051\u3066\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2,14],"tags":[],"class_list":{"0":"post-877","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-it","7":"category-14","8":"h-entry","9":"hentry","10":"h-as-article"},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/roroing.net\/index.php?rest_route=\/wp\/v2\/posts\/877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/roroing.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/roroing.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/roroing.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/roroing.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=877"}],"version-history":[{"count":1,"href":"https:\/\/roroing.net\/index.php?rest_route=\/wp\/v2\/posts\/877\/revisions"}],"predecessor-version":[{"id":878,"href":"https:\/\/roroing.net\/index.php?rest_route=\/wp\/v2\/posts\/877\/revisions\/878"}],"wp:attachment":[{"href":"https:\/\/roroing.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/roroing.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/roroing.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}