0

I have this command that creates a working ssh tunnel for access to MySQL server:

ssh -f test@remotehost -L 127.0.0.1:3306:mysqlhost:3306 -N

Here, remotehost is accessible only via jump host which I configured with the help of ProxyCommand in .ssh/config:

Host somehost
  Hostname jumphost-name
  ForwardAgent yes
  ControlPath ~/.ssh/cm-%r@%h:%p
  ControlMaster auto
  ControlPersist 10m

Host *.example.com 
  User test
  StrictHostKeyChecking no
  ProxyCommand ssh -X -4 test@somehost nc %h %p

How can I do the same using expect tool?

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
user541
  • 3
  • 1

1 Answers1

0

expect is a framework for processing input/output from some sort of TCP connection. It can support ssh, sure... but it certainly does not understand the mysql protocol. Most of the communication in the mysql protocol itself is binary data... and the last time I examined expect, it was incapable of parsing binary data properly. You might be better off writing a wrapper to the mysql client, which would require you to start mysql after connecting via ssh.

TheCompWiz
  • 7,349
  • 16
  • 23