Archive for 2009/3/4

expectを使ってSSHのパスワードを自動的に入力する。
ただし、この方法はどこかにプレーンでパスワードを持っておく必要があるのでその点は、注意。

以下のサンプルはリモートのホームディレクトリをバックアップ


#!/usr/bin/expect -f
set timeout 20
spawn /home/hoge/exec.sh
expect "*?assword:*"
send "********\r"
expect eof

/home/hoge/exec.shの内容


#!/bin/sh
ssh -l hoge hoge.hoge.jp tar - cfz /home/hoge/ > /home/hoge/hoge.tar.gz


vi /etc/ssh/sshd_config
PermitRootLogin no
/etc/init.d/sshd reload


これでOK

ソフトウェア&ライブラリ



ライブラリ
airxmail(en)
AIR版メール送受信ライブラリ
airxzip
AIR版ZIP圧縮・解凍ライブラリ
カレンダー
2009年3月
    4月 »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

カスタム検索
RSS
Add to Google
にほんブログ村 IT技術ブログへ