Skip to content

Enhancement Request: Allow ssh communicator using ssh cli #13817

Description

@loynoir

Is your feature request related to a problem? Please describe.

I'm frustrated when I found:

There is no way let ssh communicator using ssh cli, even

  • VAGRANT_PREFER_SYSTEM_BIN=1

  • config.ssh.ssh_command = "/path/to/custom/ssh/wrapper"

Describe the solution you'd like

Allow ssh communicator using ssh cli

  • when set config.communicator.ssh.ssh_command, use it

  • when set config.ssh.ssh_command, use it

  • when set VAGRANT_PREFER_SYSTEM_BIN=1, use ssh in PATH

  • fallback to pure ruby ssh implementation

Describe alternatives you've considered

Nope.

Additional context

prepare

/path/to/custom/ssh/wrapper

#!/bin/bash

echo "ssh $*" >> /tmp/q.log

# sleep to prevent ruby net-ssh retry leads to ugly warning
sleep 60

exec ssh "$@"

Vagrantfile

Vagrant.configure("2") do |config|
  ...
  config.ssh.ssh_command = "/path/to/custom/ssh/wrapper"
  ...
end

reproduce

/tmp/q.log is not triggered

$ tail -f /tmp/q.log &
$ VAGRANT_PREFER_SYSTEM_BIN=1 vagrant up
...
    default: SSH address: XXX
    default: SSH username: XXX
    default: SSH auth method: XXX
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
...

trace

Seems caused by

https://github.com/hashicorp/vagrant/blob/main/plugins/communicators/ssh/communicator.rb#L101

Seems caused by Pure Ruby implementation of an SSH (protocol 2) client

https://github.com/net-ssh/net-ssh

similar

https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

net.git-fetch-with-cli

If this is true, then Cargo will use the git executable to fetch registry indexes and git dependencies.
If false, then it uses a built-in git library.

https://github.com/rust-lang/cargo/blob/master/src/cargo/sources/git/utils.rs#L1087-L1093

cargo provide using git cli ability on top of pure rust git implementation libgit2.

Would be nice to have:

  • vagrant provide using ssh cli ability on top of pure ruby ssh implementation net-ssh.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions