Expect登陆没有公钥的服务器

| | Comments (0) | TrackBacks (0)

公司有几台服务器总是不能把自己的ssh-pubkey放上去,每一次输入那一长串的东东实在是无法忍受。看了一下expect像样的文档没有一个,倒是有一堆的例子,学习下,放在这里备忘吧。

#!/usr/bin/env expect 
set timeout -1 #设置超时的时间,单位是秒,-1是永不超时
set password ****  #设置变量
set host [lindex $argv 0] #设置一个变量是从命令行参数得到
spawn ssh guixing@$host #来来来,下个蛋
expect "assword:" #等的就是它了
send -- "$password\r" #发出去
interact #剩下的就是自己的了

0 TrackBacks

Listed below are links to blogs that reference this entry: Expect登陆没有公钥的服务器.

TrackBack URL for this entry: http://blog.khsing.net/cgi-bin/mt-tb.cgi/9

Leave a comment

About this Entry

This page contains a single entry by Guixing published on February 26, 2008 6:19 PM.

Emacs.app was the previous entry in this blog.

Pseudocode伪代码,逻辑代码? is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.21-en