‘vagrant ssh’ errors

I picked up a copy of Learning Puppet 4 shortly after publication and went through some of the examples and exercises. Pretty straightforward, although there were a few glitches in the examples, as is typical with any fast-moving technology. The book’s errata addressed all of these, as far as I recall.

So now it’s about two years later, and I wanted to revisit the learning environment. Of course there have been updates to just about everything, so my first task was updating VirtualBox, Vagrant, Xcode (I’m on a Mac), the learning repository, and the vagrant plugin. After going through all that, I tried to start up the first client VM:

$ vagrant up client
Bringing machine 'client' up with 'virtualbox' provider...
(lots of output omitted)
==> client: Checking for guest additions in VM...
==> client: Setting hostname...
==> client: Configuring and enabling network interfaces...
    client: SSH address: 127.0.0.1:2222
    client: SSH username: vagrant
    client: SSH auth method: private key
==> client: Rsyncing folder: /path/to/learning-puppet4/ => /vagrant
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /path/to/learning-puppet4/
Guest path: /vagrant
Command: "rsync" "--verbose" "--archive" "--delete" "-z" "--copy-links" "--no-owner" "--no-group" "--rsync-path" "sudo rsync" "-e" "ssh -p 2222 -o LogLevel=FATAL  -o ControlMaster=auto -o ControlPath=/var/folders/6s/_lvgcgf10395112fqhvwlr1hv5_gdx/T/ssh.804 -o ControlPersist=10m  -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i '/path/to/learning-puppet4/.vagrant/machines/client/virtualbox/private_key'" "--exclude" ".vagrant/" "/path/to/learning-puppet4/" "vagrant@127.0.0.1:/vagrant"
Error: channel 0: open failed: connect failed: Connection refused
stdio forwarding failed
ssh_exchange_identification: Connection closed by remote host
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/io.c(453) [sender=2.6.9]

Just before I ran vagrant up, I had been re-reading the book’s section on the vbguest plugin, and I got fixated on this:

In particular, this plugin helps avoid problems that happen when a new kernel is installed, such as the /vagrant shared mount not being available.

So I thought vbguest might be the cause of my problem. (Hint: it wasn’t!) I spent an inordinate amount of time deleting and re-installing everything, multiple times. When I finally hit upon the obvious idea of copy/pasting that very long rsync command into a terminal window, I quickly zeroed in on the underlying issue: my ~/.ssh/config file’s default settings will only work with the servers I manage for my employer. (Settings which I implemented after I had originally set up my ‘Learning Puppet 4’ environment.) I’m not going to go over the details, but as soon as I suspected that this might be the problem, it was pretty easy to verify:

$ mv -i ~/.ssh/config{,.save}    # Move config file out of the way

$ vagrant destroy client
    client: Are you sure you want to destroy the 'client' VM? [y/N] y
==> client: Forcing shutdown of VM...
Connection to 127.0.0.1 closed by remote host.
==> client: Destroying VM and associated drives...

$ vagrant up client
Bringing machine 'client' up with 'virtualbox' provider...
(lots of output omitted)
==> client: Rsyncing folder: /path/to/learning-puppet4/ => /vagrant
==> client: Running provisioner: shell...
    client: Running: inline script

At least I didn’t get an error on rsync this time! Now to test logging in:

$ vagrant ssh client

You should start by enabling the Puppet Labs Puppet Collection 1 release repo
   sudo yum install http://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm

Then install Puppet Agent and its companion packages
   sudo yum install -y puppet-agent

[vagrant@client ~]$ 

Success!

I’ve restored my original ssh config file, with a new Host section for the learning environment’s virtual machine. I may need to add more Hosts for the other VM’s, but hopefully I’ll remember to check here for hints if I run into this issue again.

The ssh options that I find most useful for diagnosing problems are -v (or -vv or -vvv) for verbose protocol status while initiating and breaking a connection, and -G which causes ssh to print its configuration after evaluating Host and Match blocks. To enter these options as part of a vagrant ssh connection, specify them after the target like so:

$ vagrant ssh client -- -G

About Jim Vanderveen

I'm a bit of a Renaissance man, with far too many hobbies for my free time! But more important than any hobby is my family. My proudest accomplishment has been raising some great kids! And somehow convincing my wife to put up with me since 1988. ;)
This entry was posted in FreeBSD and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *