Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Add OpenSSH to Windows Images #332

Closed
abbbi opened this issue Oct 13, 2021 · 4 comments
Closed

Add OpenSSH to Windows Images #332

abbbi opened this issue Oct 13, 2021 · 4 comments
Labels

Comments

@abbbi
Copy link
Contributor

abbbi commented Oct 13, 2021

hi,

it would be neat to have OpenSSH portable from:

https://github.com/PowerShell/openssh-portable

in the windows images to be able to use ssh during provisioning instead of winrm only.

@ruzickap
Copy link
Owner

All Windows images should have OpenSSH installed and password-less vagrant ssh should work too...
Let me know if it is working for you.

@abbbi
Copy link
Contributor Author

abbbi commented Oct 18, 2021

hi,

i tried with the server 2019 images but they seem to have issues with the key based auth. Strange enough
it suceeds inserting the new keypair but then fails in further steps ..

==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 10.0.0.192:22
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection refused. Retrying...
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...

Not quite sure whats going on here, i can see that the key has been added to the vagrant users authorized keys file:

vagrant@VAGRANTVM C:\Users\vagrant\.ssh>type authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCYCydljY3z4vNnqekuEjHz2xMKWiYPdlcUZrOclazAZveKW0Z/6E+37PjVRE1n6+jhQprtWRPd4nYN2UPciGzdm3JUAkSRitXK
xo5XRECWX5aEGawVCoy0zBsbbBl/mmfP+Fs8j9wkrWZCIo2ogbSXnXo8TXA68PIt64y0L9p7Xw2lqhtCq1M2jimr6cgcFIny3AiBl4jrdKd2G5D2qHmv4JmgUVJRbsZDUm7rNiEO
xnXBR5OzYJ+pPHbotJWvadbEPJwAlm0+GTV7sJ2H84Ni8v1ff95ihaBP6W5drbKpmV9ROViEKphDgQcOqNlDXwKu/gTfWkGXLkyvrYwZop9D vagrant

but for some reason sshd doesnt accept the keypair:

ssh -i .vagrant/machines/default/libvirt/private_key [email protected]
The authenticity of host '10.0.0.75 (10.0.0.75)' can't be established.
ECDSA key fingerprint is SHA256:Jey8ZEchzb8Xx0WBqA01drGjDxQdEi7wQOWhxISSwmw.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.0.75' (ECDSA) to the list of known hosts.
[email protected]'s password: 

from ssh event log:

sshd: Failed publickey for vagrant from 10.0.0.1 port 42612 ssh2: RSA SHA256:FfauDpvTavQMmJWJ5nhHO3IOukbM6cylDxqZ+2kVIxc

@ruzickap
Copy link
Owner

ruzickap commented Oct 19, 2021

I tested it with Win server 2019 images + VirtualBox and it's working fine there.
I have trouble to run vagrant-libvirt on MacOS :-(

I successfully installed the "vagrant libvirt plugin"

brew install libvirt
brew services start libvirt

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 CONFIGURE_ARGS="with-libvirt-include=$(brew --prefix libvirt)/include with-libvirt-lib=$(brew --prefix libvirt)/lib" vagrant plugin install vagrant-libvirt

Then I changed the Vagrantfile paramaters:

mkdir windows-server-2019-standard-x64-eval
cd windows-server-2019-standard-x64-eval
vagrant init peru/windows-server-2019-standard-x64-eval

# Add

  config.vm.provider :libvirt do |libvirt|
    libvirt.driver = 'qemu'
    # Use QEMU session instead of system connection
    libvirt.qemu_use_session = true
    libvirt.qemuargs :value => '-machine'
    libvirt.qemuargs :value => 'accel=hvf'
    libvirt.video_type = 'cirrus'
    libvirt.graphics_type = 'vnc'
  end

VAGRANT_DEFAULT_PROVIDER=libvirt vagrant up

But it ends up with error:

==> default: Creating shared folders metadata...
Traceback (most recent call last):
	59: from /opt/vagrant/embedded/gems/2.2.18/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
	58: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'
...
	 2: from /Users/ruzickap/.vagrant.d/gems/2.7.4/gems/vagrant-libvirt-0.6.3/lib/vagrant-libvirt/action/create_network_interfaces.rb:291:in `interface_network'
	 1: from /Users/ruzickap/.vagrant.d/gems/2.7.4/gems/vagrant-libvirt-0.6.3/lib/vagrant-libvirt/util/network_util.rb:143:in `libvirt_networks'
/Users/ruzickap/.vagrant.d/gems/2.7.4/gems/vagrant-libvirt-0.6.3/lib/vagrant-libvirt/util/network_util.rb:143:in `list_networks': Call to virConnectNumOfNetworks failed: this function is not supported by the connection driver: virConnectNumOfNetworks (Libvirt::RetrieveError)

Seems like I hit this bug: vagrant-libvirt/vagrant-libvirt#1017

@stale
Copy link

stale bot commented Nov 9, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 9, 2021
@stale stale bot closed this as completed Nov 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants