文档详情

用Expect实现Linux自动远程登陆.pdf

发布:2017-11-06约1.81万字共3页下载文档
文本预览下载声明
NETWORKANDCOMMUNICAⅡ0N 网络与通信 用Expect实现 Linux自动远程登陆 徐冰 (德州职业技术学院,山东 德州 253034) 摘 要:利用Expect和SSH,实现 自动输入密码实现远程登录,从而简化登录过程中由于输入密码或输 出密码造成 的时间浪费,并在大规模系统中可以通过脚本来实现远程操作,从而实现多机之间的协同交互。 关键词:远程登录 ;自动登录 ;远程操作 ;SSH协议 ;Expect工具 AutoRemoteLoginwithExpect XU Bing (DezhouVocationalandTechnicalCollege,ShnadongDezhou,253034,China) Abstract:Thisarticleimplementremotelogin andremoteoperationwithexpectbywhichwecaneasilylogintoremote machineandalsocandosomeremoteoperation. Keywords:RemoteLogin;AutoLogin;RemoteOperation;SSH agreement;Expecttool 随着 Linux的流行 .在当前软件领域远程登录和远程操作 echo”Usage:、basename$0、 [一a] [一d】 一【Pport] -【p 变得 越来越 常见 ,有非 常著名 的远程登 录软件如 telnet, password] 一【ttimeout] [user@】ip c【ommnad]” echo ” 一a :runremotecommandasadmin” rlogin。ssh,其 中以ssh最为常用和安全 。但是传统的 ssh进 echo” 一d:echodebuginfoexceptpasswd” 行远程登录或操作时需要用户在终端输入密码来认证用户信 echo” 一Pport:defaultportis22,youcanchangeitwith 息,这大大降低了ssh的易用性。通过 expect来对 ssh进行包 hteoption’’ 装 .在不丧失安全性 的同时获得极大 的易用性 ,从而大大提 echo _ppassword :defaultpasswordisdefined in 一/.pwd 高远程登录和远程操作 的效率 ,并使得远程操作脚本化成为 file.everysuccessloginwillupdatethepasswordin一|.pwdfile。 可能。从而极大提高脚本的远程交互能力 。 echo”-ttimeout:defaulttimeoutiS1200second (20m)” echo u【ser]@ip:defaultloginuseriscurrentlocaluser l 使用技术 echo ” command :ht
显示全部
相似文档