Home > OS >  Expect script ordinary users switch after root, unable to send password, authentication failure, why
Expect script ordinary users switch after root, unable to send password, authentication failure, why

Time:11-19

SSH to the server is no problem, once the spawn after su - root, has been to stay in the input password, like "send system " r "is not sent in the past, is what reason,
The code below
 #! The/usr/bin/expect 
Set the timeout of 10
Spawn SSH [email protected]
Expect "* assword:" {send 19 \ r "" l * kj @}

Spawn su - root
Expect "password *" {send system \ "r"}
Send "the PWD \ r"

Interact

Error is as follows:
 [ladmin @ localhost ~] $spawn su - root 
Password:
Su: authentication failed

CodePudding user response:

Use of the operating system is Redhat7.5 Redhat6.7

CodePudding user response:

Has been resolved,
#! The/usr/bin/expect
Set the timeout of 10
Spawn SSH [email protected]
Expect "* assword:" {send 19 \ r "" l * kj @}

send "su - root \ r"
Expect "password *" {send system \ "r"}
Send "the PWD \ r"

interact
  • Related