spatie/ssh

Bug: Using public setTimeout creates invalid SSH commands

Closed this issue · 1 comments

Hello!

I noticed when using this package in production that using the setTimeout function actually causes the resulting SSH command to be invalid. If you add this test:

it('setting timeout does not alter ssh command', function () {
    $command = $this->ssh->setTimeout(10)->getExecuteCommand('whoami');

    assertMatchesSnapshot($command);
});

You will see this result:

ssh 10 user@example.com 'bash -se' << \EOF-SPATIE-SSH
whoami
EOF-SPATIE-SSH

When checking the ssh man page, it seems that the correct usage is to pass it in as an option as -o ConnectTimeout=10. But instead it is serialized as an integer due to the way getExecuteCommand turns everything in the $this->extraOptions array to a string.

Though I do see that this option is intended to merely pass the integer to Symfony's Process class.

Thanks for the PR 👍