Commit caa280f6 authored by 孙 楠's avatar 孙 楠

适配jumpserver

parent c397da5e
...@@ -5,10 +5,10 @@ if [ -n "$AUTO_LOGIN_HOME" ] ; then ...@@ -5,10 +5,10 @@ if [ -n "$AUTO_LOGIN_HOME" ] ; then
. "$AUTO_LOGIN_HOME/config" . "$AUTO_LOGIN_HOME/config"
token=$(python3 "$AUTO_LOGIN_HOME/onetimepass.py") token=$(python3 "$AUTO_LOGIN_HOME/onetimepass.py")
# echo ${token} # echo ${token}
expectlogin.sh ${username} ${password} ${host} ${token} expectlogin.sh ${username} ${password} ${host} ${token} ${port}
else else
echo "AUTO_LOGIN_HOME not config" echo "AUTO_LOGIN_HOME not config"
. config . config
token=$(python3 onetimepass.py) token=$(python3 onetimepass.py)
./expectlogin.sh ${username} ${password} ${host} ${token} ./expectlogin.sh ${username} ${password} ${host} ${token} ${port}
fi fi
\ No newline at end of file
username=name username=name
password=password password=password
host=fort-qz.quantgroups.com host=jumpserver.quantgroups.com
secret=XXXXXXX secret=XXXXXXX
\ No newline at end of file port=2222
\ No newline at end of file
...@@ -12,14 +12,15 @@ set username [lindex $argv 0] ...@@ -12,14 +12,15 @@ set username [lindex $argv 0]
set password [lindex $argv 1] set password [lindex $argv 1]
set host [lindex $argv 2] set host [lindex $argv 2]
set otp [lindex $argv 3] set otp [lindex $argv 3]
set port [lindex $argv 4]
set timeout 10 set timeout 10
spawn ssh "${username}@${host}" spawn ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa "${username}@${host}" -p "${port}"
expect { expect {
"Password" "password"
{send "$password $otp\n";exp_continue} {send "$password\n";exp_continue}
"Select group" "OTP Code"
{send 0\n0\n;exp_continue} {send "$otp\n";exp_continue}
} }
interact interact
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment