Hello,
I need to connect to multiple servers from a local machine with a root password. I need to connect to a server over ssh, perform a command, exit and connect to the next server. Usual thing, I would say. Of course, there are some good examples in the internet. The most suitable is the one listed below:
Code:
##!/bin/bash
set -x
host="hostname"
user=root
passw='password'
cmd='ls -la'
socket=$(expect -c "
spawn ssh -o StrictHostKeyChecking=no $user@$host $cmd
match_max 100000
expect \"*password:*\"
send -- \"$passw\r\"
send -- \"\r\"
expect eof
")
echo "$socket"
This script connects fine at home to my server set up in VirtualBox. But I cannot connect at work. I am attaching a file with all output I see. I would be grateful for any help. Of course I am replacing password and hostname. I assure you I set the correctly them with no typos.