{"id":406,"date":"2011-01-28T00:30:38","date_gmt":"2011-11-04T05:51:50","guid":{"rendered":"http:\/\/kraftek.com\/blog\/automate-ssh-login-with-expect\/"},"modified":"2011-01-28T00:30:38","modified_gmt":"2011-11-04T05:51:50","slug":"automate-ssh-login-with-expect","status":"publish","type":"post","link":"\/blog\/index.php\/automate-ssh-login-with-expect\/","title":{"rendered":"Automate ssh login with expect"},"content":{"rendered":"<p>Sometimes you are not allowed to use keys to autologin to your machines, so you must find a way to automate your<br \/>\nlogin using password authentication.<br \/>\nThis expect script can help you do it:<br \/>\n#!\/usr\/local\/bin\/expect &#8212;<br \/>\nset timeout 30<br \/>\nspawn ssh user@ipaddress<br \/>\nwhile 1 {<br \/>\nexpect {<br \/>\n&#8220;*(yes\/no)?&#8221; { send &#8220;yesn&#8221;}<br \/>\n&#8220;*password:&#8221; { send &#8220;passwordn&#8221;}<br \/>\n&#8220;*user]#&#8221; { send &#8220;shutdown -h nownexitn&#8221;}<br \/>\n}<br \/>\n}<br \/>\n266\/433<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you are not allowed to use keys to autologin to your machines, so you must find a way to automate your login using password authentication. This expect script can help you do it: #!\/usr\/local\/bin\/expect &#8212; set timeout 30 spawn ssh user@ipaddress while 1 { expect { &#8220;*(yes\/no)?&#8221; { send &#8220;yesn&#8221;} &#8220;*password:&#8221; { send &#8220;passwordn&#8221;} [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-406","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=406"}],"version-history":[{"count":0,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/406\/revisions"}],"wp:attachment":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}