From 8d6545f7b6e5da69fe2e71a1dfc5201b1f048802 Mon Sep 17 00:00:00 2001 From: loufei Date: Tue, 2 Jan 2018 20:14:42 +0800 Subject: [PATCH 1/5] add dir in expect mode --- so.sh | 4 ++-- ssh_login.exp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/so.sh b/so.sh index d3b6dbb..8158bc5 100755 --- a/so.sh +++ b/so.sh @@ -49,7 +49,7 @@ while [ True ];do port=$(awk -v num=$number 'BEGIN {FS=":"} {if($1 == num) {print $3}}' $pw) username=$(awk -v num=$number 'BEGIN {FS=":"} {if($1 == num) {print $4}}' $pw) passwd=$(awk -v num=$number 'BEGIN {FS=":"} {if($1 == num) {print $5}}' $pw) - + dir=$(awk -v num=$number 'BEGIN {FS=":"} {if($1 == num) {print $7}}' $pw) case $number in [0-9]|[0-9][0-9]|[0-9][0-9][0-9]) echo $passwd | grep -q ".pem$" @@ -58,7 +58,7 @@ while [ True ];do ssh -i $direc/keys/$passwd $username@$ipaddr -p $port echo "ssh -i $direc/$passwd $username@$ipaddr -p $port" else - expect -f $direc/ssh_login.exp $ipaddr $username $passwd $port + expect -f $direc/ssh_login.exp $ipaddr $username $passwd $port $dir fi ;; "q"|"quit") diff --git a/ssh_login.exp b/ssh_login.exp index 13aaa26..aac7f5d 100755 --- a/ssh_login.exp +++ b/ssh_login.exp @@ -3,11 +3,14 @@ set TARGET [lindex $argv 0] set USER [lindex $argv 1] set PASSWD [lindex $argv 2] set PORT [lindex $argv 3] +set DIR [lindex $argv 4] set timeout 10 -spawn ssh $USER@$TARGET -p $PORT +spawn ssh $USER@$TARGET -p $PORT +#'cd /root/' expect { "*yes/no" {send "yes\r"; exp_continue} "*password:" {send "$PASSWD\r"} } +send "cd $DIR\r" interact From 8119c20f8d872e6b8ca0aa56213f37b2216329d8 Mon Sep 17 00:00:00 2001 From: loufei Date: Tue, 2 Jan 2018 20:40:46 +0800 Subject: [PATCH 2/5] add qwd --- ssh_login.exp | 1 + 1 file changed, 1 insertion(+) diff --git a/ssh_login.exp b/ssh_login.exp index aac7f5d..9f3c694 100755 --- a/ssh_login.exp +++ b/ssh_login.exp @@ -13,4 +13,5 @@ expect { "*password:" {send "$PASSWD\r"} } send "cd $DIR\r" +send "pwd" interact From a13e1474281b32043c65e38f3143630edbb8edfe Mon Sep 17 00:00:00 2001 From: loufei Date: Tue, 2 Jan 2018 20:43:10 +0800 Subject: [PATCH 3/5] add \r --- ssh_login.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssh_login.exp b/ssh_login.exp index 9f3c694..a10ea99 100755 --- a/ssh_login.exp +++ b/ssh_login.exp @@ -13,5 +13,5 @@ expect { "*password:" {send "$PASSWD\r"} } send "cd $DIR\r" -send "pwd" +send "pwd\r" interact From 46cccc90348c5bd1eec0fde53e8fabcad67b09ce Mon Sep 17 00:00:00 2001 From: fei33423 Date: Wed, 3 Jan 2018 16:05:02 +0800 Subject: [PATCH 4/5] Update password.lst --- password.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/password.lst b/password.lst index 32e26c0..3e02f22 100755 --- a/password.lst +++ b/password.lst @@ -1,3 +1,3 @@ -1:192.168.88.128:22:root:toor:虚拟机web服务器 +1:192.168.88.128:22:root:toor:虚拟机web服务器:/root/ 2:192.168.88.130:22:ca0gu0:toor:虚拟机mysql数据库服务器 103:192.168.88.4:22:root:sellercube:本地开发服务器 From 0cc7a8be1888037702a18b9855c94a03c2080056 Mon Sep 17 00:00:00 2001 From: fei33423 Date: Wed, 3 Jan 2018 16:05:16 +0800 Subject: [PATCH 5/5] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0b0c0f1..88bb4ef 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# update by fei33423 + 新增登录后 cd 到指定的路径. 配置文件中最后一列 + 1:192.168.88.128:22:root:toor:虚拟机web服务器:/root/ + # so This is a SSH login tool