{"id":40316,"date":"2024-11-26T15:27:54","date_gmt":"2024-11-26T07:27:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/40316\/"},"modified":"2024-11-26T15:27:54","modified_gmt":"2024-11-26T07:27:54","slug":"ssh%e5%af%86%e7%a0%81%e9%aa%8c%e8%af%81%e7%bb%95%e8%bf%87","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/40316\/","title":{"rendered":"SSH\u5bc6\u7801\u9a8c\u8bc1\u7ed5\u8fc7"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173173520113038.jpg\" class=\"aligncenter\" title=\"SSH\u5bc6\u7801\u9a8c\u8bc1\u7ed5\u8fc7\u63d2\u56fe\" alt=\"SSH\u5bc6\u7801\u9a8c\u8bc1\u7ed5\u8fc7\u63d2\u56fe\" \/><\/p>\n<p><strong>1. \u5b89\u88c5<\/strong>   <\/p>\n<pre>  Desktop sudo yum install sshpass\n[sudo] password for xuyaowen: \nLast metadata expiration check: 0:04:22 ago on Mon 02 Jul 2018 11:25:32 AM CST.\nPackage sshpass-1.06-5.fc28.x86_64 is already installed, skipping.\nDependencies resolved.\nNothing to do.\nComplete!\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u68c0\u67e5\u662f\u5426\u5b89\u88c5<\/p>\n<pre>[root@yaowenxu Desktop]# rpm -qa sshpass\nsshpass-1.06-5.fc28.x86_64\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236<br \/>\n<strong>2. \u67e5\u770b sshpass \u547d\u4ee4\u5e2e\u52a9, \u4e5f\u53ef\u4ee5\u4f7f\u7528 man sshpass<\/strong>  <\/p>\n<p>View Code<\/p>\n<pre>[root@yaowenxu Desktop]# sshpass\nUsage: sshpass [-f|-d|-p|-e] [-hV] command parameters\n   -f filename   Take password to use from file\n   -d number     Use number as file descriptor for getting password\n   -p password   Provide password as argument (security unwise)\n   -e            Password is passed as env-var \"SSHPASS\"\n   With no parameters - password will be taken from stdin\n\n   -P prompt     Which string should sshpass search for to detect a password prompt\n   -v            Be verbose about what you're doing\n   -h            Show help (this screen)\n   -V            Print version information\nAt most one of -f, -d, -p or -e should be used\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236<br \/>\n<strong>3. \u4f7f\u7528\u5bc6\u7801\u9a8c\u8bc1\u767b\u5f55<\/strong>   <\/p>\n<pre>  ~ sshpass -p 123 ssh root@10.66.65.15\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236<br \/>\n<strong>4. ssh \u7b2c\u4e00\u6b21\u767b\u5f55\u63d0\u793a\u95ee\u9898\u4f7f\u7528\uff1a<\/strong>  <\/p>\n<p>ssh -o StrictHostKeyChecking=no<\/p>\n<p>\u6765\u89e3\u51b3<\/p>\n<pre>  Desktop sshpass  -p 123 ssh -o StrictHostKeyChecking=no root@10.66.8.142\nWarning: Permanently added '10.66.8.142' (ECDSA) to the list of known hosts.\nLast login: Mon Jul  2 10:51:29 2018\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236<br \/>\n<strong>5. \u4f18\u7f3a\u70b9<\/strong>  <\/p>\n<p>\u4f18\u70b9\uff1a \u5feb\u901f\uff0c\u4fbf\u6377<\/p>\n<p>\u7f3a\u70b9\uff1a \u5bc6\u7801\u660e\u6587\u66b4\u9732\uff0c\u53ef\u4ee5\u4f7f\u7528 history \u547d\u4ee4\u67e5\u627e\u5230<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fSSH\u5bc6\u7801\u9a8c\u8bc1\u7ed5\u8fc7\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5b89\u88c5 Desktop sudo yum install sshpass [sudo] password for xuyaowen: Last metadata expiration check: 0:04:22 ago on Mon 02 Jul 2018 11:25:32 AM CST. Package sshpass-1.06-5.fc28.x86_64 is already installed, skipping. Dependencies resolved. Nothing to do. Complete! \u767b\u5f55\u540e\u590d\u5236 \u68c0\u67e5\u662f\u5426\u5b89\u88c5 [root@yaowenxu Desktop]# rpm -qa sshpass sshpass-1.06-5.fc28.x86_64 \u767b\u5f55\u540e\u590d\u5236 2. \u67e5\u770b sshpass \u547d\u4ee4\u5e2e\u52a9, \u4e5f\u53ef\u4ee5\u4f7f\u7528 man sshpass View Code [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-40316","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/40316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=40316"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/40316\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=40316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=40316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=40316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}