Optionally use ssh settings only with vagrant ssh command #1575
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows bootstrapping the user on a base image, by using
default ssh settings during provisioning and user defined
ssh settings when doing
vagrant ssh.TESTING INSTRUCTIONS:
user_playbooks/ssh-test.ymlto bootstrap the user (edit the usernames to match those you will test):NOTE: As written, this requires the feature to add the user's ssh public key to authorized_keys directly from github via their github username, from #1570
vagrant/boxes.d:Make sure ssh-agent is started and your private key has been added to it
Run
vagrant up fedora34-ssh-testand observe this still uses the defaultvagrantuser to run provisioning tasks, including creating the new user and managing its authorized_keys.Run
vagrant ssh-config fedora34-ssh-testand observe thessh_usernamefrom the box definition defined here, even though it was not used in step 4.Run
vagrant ssh fedora34-ssh-testand observe that it authenticates as thessh_usernamewith credentials from the ssh-agent.As the
ssh_usernameuser, logged in on fedora34-ssh-test box, test that the ssh-agent was forwarded to the box by using the stored credentials to authenticate to github:ssh -T [email protected]EXPECTED RESULTS:
vagrant upuses the defaultvagrantuser instead ofssh_username, whilevagrant ssh-configandvagrant sshusessh_username. all above steps are successfulACTUAL RESULTS (prior to this commit):
vagrant upfails as it tries to use thessh_usernamewhich doesn't exist until after provisioning has been run. It will appear to hang onwaiting for ssh to become availablewhile addingVAGRANT_LOG=debugwill show it attempting the connection with the not-yet-existing user.