Reputation: 21
I have a situation where I need to, using robot framework, ssh to host1 and then to host2 from my local mac machine, as there is no route to host2 directly. I tried opening second connection after opening the first connection but this didn't work.
Test nested ssh connections
Open Connection ${host1}
Login ${host1-user} ${host1-pw}
${output}= Execute Command hostname
log to console ${\n}${output}
Open Connection ${host2} #there is no pw
${output}= Execute Command hostname
log to console ${\n}${output}
output:
Open Connection And Log In ...
host1
14:17:59 up 44 days, 18:13, 1 user, load average: 0.00, 0.01, 0.05
Open Connection And Log In | FAIL |
Connection not open
Ican't figure out why second connection doesn't open. Is there a solution to this problem? Any help is appreciated.
Upvotes: 0
Views: 2120
Reputation: 131
After opening connection to first host, you can simply use Write, Read, Read Until keywords to login to second host. The keyword will look something like: (you can use variables, I am using hardcoded values for ip, username, password)
Test nested ssh connections
Open Connection ${host1}
Login ${host1-user} ${host1-pw}
Write ssh [email protected]
Read Until password:
Write user123
Read Until $
Upvotes: 3