0

I am writing a VM deployment tool that needed to start VMs on an ESXi server. To do this I am using Perl's Expect module to spawn an ssh client to connect to the server and use vim-cmd to manage the VM.

When I did this I would see the connection and authentication succeed (i.e. the password prompt would be shown, the password accepted and then the prompt would be returned.

Immediately after that the ssh client process outputs "Connection to xxxx closed" and my script stops.

efunneko
  • 245
  • 1
  • 3
  • 11

1 Answers1

0

It turns out that I was setting 'raw_pty(1)' on the expect session:

  my $exp = new Expect();
  $exp->raw_pty(1);

  $exp->spawn("ssh", "$args{username}\@$server");

The raw_pty was not liked by the ESXi server and it immediately closed the connection. Removing the line:

  $exp->raw_pty(1);

fixed the problem I was having.

efunneko
  • 245
  • 1
  • 3
  • 11