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.yml
to 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-test
and observe this still uses the defaultvagrant
user to run provisioning tasks, including creating the new user and managing its authorized_keys.Run
vagrant ssh-config fedora34-ssh-test
and observe thessh_username
from the box definition defined here, even though it was not used in step 4.Run
vagrant ssh fedora34-ssh-test
and observe that it authenticates as thessh_username
with credentials from the ssh-agent.As the
ssh_username
user, 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 up
uses the defaultvagrant
user instead ofssh_username
, whilevagrant ssh-config
andvagrant ssh
usessh_username
. all above steps are successfulACTUAL RESULTS (prior to this commit):
vagrant up
fails as it tries to use thessh_username
which doesn't exist until after provisioning has been run. It will appear to hang onwaiting for ssh to become available
while addingVAGRANT_LOG=debug
will show it attempting the connection with the not-yet-existing user.