这是我在ST写的自动登陆ssh的脚本, 分两个文件
文件1: sssh
#!/bin/bash #xql 2011/01/4#auto ssh 138.198.230.170 case $1 in "xql") sssh.exp xql ;; "root") sssh.exp root ;; "31") ssh [email protected]10.80.117.31 ;; "40") ssh [email protected]10.80.117.40 ;; *) ssh [email protected]138.198.230.170 ;;esac
文件2: sssh.exp
#!/usr/bin/expect set USER [ lindex $argv 0 ]set ADDR "138.198.230.170" switch $USER { "xql" {set PASS "qianli1987"} "root" {set PASS "bu60ff"} default {exit 1}} spawn ssh [email protected]$ADDR expect { "*password: " {send "$PASS\r"} "*(yes/no)? " {send "yes\r"}}interact
时间: 2024-10-07 02:00:42