Home > OS >  How to use expect for nested SSH login
How to use expect for nested SSH login

Time:01-27

Requirements:
SSH login to serverA
From A login again on serverB
Use expect to do this, the first step is very good to write, write the second step, is stuck, I understand this time need to use spawn a new process, but how to do?


#!/bin/bash

The/usr/bin/expect & lt; -Spawn SSH root @ & lt; ServerA>
Set the timeout - 1
Expect "password:"
Send "root \ n
"Expect "#"
The send date "\ n"
Send "SSH root @ & lt; ServerB> \ n "=====& gt; There are problems
Expect "password:"
Send "root \ n
"Interact

Expect eof
EOF
  • Related