Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect vagrant ssh-config output while working with --host xxx #7728

Closed
guessi opened this issue Aug 17, 2016 · 2 comments · Fixed by #7877
Closed

Incorrect vagrant ssh-config output while working with --host xxx #7728

guessi opened this issue Aug 17, 2016 · 2 comments · Fixed by #7877

Comments

@guessi
Copy link
Contributor

guessi commented Aug 17, 2016

Vagrant version

Vagrant 1.8.5

Host operating system

Fedora 24

Guest operating system

CentOS 7

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "centos/7"

  instances = [
    'node1',
    'node2',
  ]

  instances.each do |box|
    config.vm.define box
  end
end

Debug output

SKIPPED

Expected behavior

vagrant ssh-config with --host option should display "Host" correctly

Actual behavior

vargrant ssh-config with --host option show "Host" field incorrectly

$ vagrant ssh-config 
Host node1
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/xxxxxx/centos7/.vagrant/machines/node1/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

Host node2
  HostName 127.0.0.1
  User vagrant
  Port 2200
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/xxxxxx/centos7/.vagrant/machines/node2/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

$ vagrant ssh-config --host node1
Host node1
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/xxxxxx/centos7/.vagrant/machines/node1/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

Host node1
  HostName 127.0.0.1
  User vagrant
  Port 2200
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/xxxxxx/centos7/.vagrant/machines/node2/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

$ vagrant ssh-config --host node2
Host node2
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/xxxxxx/centos7/.vagrant/machines/node1/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

Host node2
  HostName 127.0.0.1
  User vagrant
  Port 2200
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/xxxxxx/centos7/.vagrant/machines/node2/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

Steps to reproduce

  1. vagrant ssh-config, without --host flag
  2. vagrant ssh-config, with --host flag

References

N/A

@chrisroberts
Copy link
Member

Hi! After looking through the code and history more closely, this is the expected behavior. The --host flag allows setting a custom host to use for a given vm requested. Using your example given above, if you wanted only the information for node1, you would run:

$ vagrant ssh-config node1
Host node1
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/xxxxxx/centos7/.vagrant/machines/node1/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

If you wanted the host to be different than the defined vm name within the Vagrantfile, the --host option allows you to do that:

$ vagrant ssh-config node1 --host my-node
Host my-node
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/xxxxxx/centos7/.vagrant/machines/node1/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

Apologies for the confusion. Thanks!

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants