teratern自動ログイン設定

via http://sourceforge.jp/magazine/10/01/08/0825239
を参考に。
俺の場合一旦suしてから対象ユーザにsuし直すから(パスワード覚えなくていいから楽)、とりあえず一気にsuするようにしました。

ツールはteratermpro UTF-8 ver4.67

.ttlファイル作成

サーバ名.ttl

.ttl内で使えるコマンドピックアップ

getpassword [パスワードファイル] [キー] [保存先変数名]
  • 最初の一回だけ入力を求められる
  • 入力した内容はパスワードファイルに保存される
  • 次回以降はパスワードファイルから読み出される
  • 一行でおいしい便利オペコード
strconcat [変数] [文字]
  • [変数]に[文字]を足す。左辺値は受け取り
callmenu [番号]

認証鍵使うやつ

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
username = 'user'
rootname = 'root'
hostname = 'example.jp'
passwdfile = 'C:\hogehoge\terminal\password.dump';
keyfile = 'C:\hogehoge\terminal\ssh_key\cert'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; user password
passwdkey = username
strconcat passwdkey '@'
strconcat passwdkey hostname
getpassword passwdfile passwdkey userpass

; root password
passwdkey = rootname
strconcat passwdkey '@'
strconcat passwdkey hostname
getpassword passwdfile passwdkey rootpass


msg = hostname
strconcat msg ':22 /ssh /1 /auth=publickey /user='
strconcat msg username
strconcat msg ' /keyfile='
strconcat msg keyfile
strconcat msg ' /passwd="'
strconcat msg userpass
strconcat msg '"'
connect msg

timeout=15

;文字コードをeuc-jp
callmenu 54011

; su
wait '$'
sendln 'su -'
Wait ':'
sendln rootpass

認証鍵不要

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
username = 'user'
rootname = 'root'
hostname = 'example.com'
passwdfile = 'C:\hogehoge\terminal\password.dump';
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; user password
passwdkey = username
strconcat passwdkey '@'
strconcat passwdkey hostname
getpassword passwdfile passwdkey userpass

; root password
passwdkey = rootname
strconcat passwdkey '@'
strconcat passwdkey hostname
getpassword passwdfile passwdkey rootpass


msg = hostname
strconcat msg ':22 /ssh /2 /auth=password /user='
strconcat msg username
strconcat msg ' /passwd='
strconcat msg userpass

connect msg
timeout=15


; su
wait '$'
sendln 'su -'
Wait ':'
sendln rootpass