Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion password.lst
Original file line number Diff line number Diff line change
@@ -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:本地开发服务器
4 changes: 2 additions & 2 deletions so.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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$"
Expand All @@ -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")
Expand Down
6 changes: 5 additions & 1 deletion ssh_login.exp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ 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"
send "pwd\r"
interact