Commit Graph

234 Commits

Author SHA1 Message Date
Chris Roberts 3ca8089920 Remove require of net/sftp library
Fixes #10733
2019-03-20 13:02:08 -07:00
Chris Roberts e2b6a6645c Always ensure remote destination directory exists 2019-02-26 08:54:49 -08:00
Chris Roberts 6b105d704d Update communicator upload behavior to handle `/.` path directives
This update was prompted by updates in openssh to the scp behavior
making source directory paths suffixed with `.` no longer valid
resulting in errors on upload. The upload implementation within
the ssh communicator has been updated to retain the existing
behavior.

Included in this update is modifications to the winrm communicator
so the upload functionality matches that of the ssh communicator
respecting the trailing `.` behavior on source paths. With the
communicators updated to properly handle the paths, the file
provisioner was also updated to simply apply previously defined
path update rules only.

Fixes #10675
2019-02-26 08:02:09 -08:00
Chris Roberts d87c645bd0 Fix garbage detection within SSH communicator
Fixes #10552
2019-01-07 16:20:56 -08:00
Chris Roberts 480bb47e1d
Merge pull request #10496 from chrisroberts/e-ssh-config-file
Add support for config and remote_user to SSH options
2018-12-13 09:16:49 -08:00
Gavin Williams 122ef7307c Flesh out `:config` support.
Also noticed whilst testing that if the `ProxyCommand` uses `%r`, then
it fails with `unable to find remote user`, so added support for
`config.ssh.remote_user` aswell
2018-12-11 07:51:47 -08:00
Gavin Williams 87e38a0bed Remove 'config' from ssh.defaults, and instead setup in '.connect' 2018-12-11 07:51:47 -08:00
Gavin Williams 87437317dc Add support for passing ssh config file in via config 2018-12-11 07:51:47 -08:00
Chris Roberts 24cd988d39 Only modify elevated username under specific conditions
Elevated commands can fail via winrm under certain conditions like
the machine name being changed. Detect this by checking for a known
exit code combined with known output included within stderr. If found,
attempt to re-execute the command using a machine prefixed username
if possible.
2018-12-07 12:11:17 -08:00
Chris Roberts afc138478d Add reset! method to winrm communicator 2018-11-12 15:36:21 -08:00
Chris Roberts 747dd9301b Add reset! to ssh communicator. Reduce number of ssh info prints. 2018-11-12 15:36:21 -08:00
Chris Roberts c8f431cf44 Prepend computer name to user when created scheduled tasks
When running a shell provisioner elevated with winrm a scheduled
task is created to bypass permissions issues. If the name of the
computer has changed this may no longer work. To prevent errors
this PR updates the implementation to fetch the computer name
and prepends it to the username before creating the task.
2018-11-08 14:21:20 -08:00
Brian Cain 54c8ebc31a
Fixes #10229: Add timeout for changing hostname on windows
Prior to this commit, if Windows was slow to reboot, Vagrant would fail
to find the right IP address to upload the wait_for_reboot script to.
This commit fixes this race condition by adding a timeout to ensure that
Vagrant can retry. It also properly catches an exception in the winrm
ready? method for checking if a guest is properly ready for
communications.
2018-11-02 09:23:00 -07:00
Chris Roberts 8562daf85e Prevent overly verbose output from SSH communicator
If the type of error changes on retry the messages will effectively
spam the user display with alternating messages. Log each message
sent and only re-display each message once within 10 seconds.
2018-10-19 15:18:03 -07:00
Chris Roberts dcfb84893d Only reset the _init on testing cleanup 2018-07-30 14:44:36 -07:00
Chris Roberts cd7215ab13 Add warning when vagrant-winrm is found 2018-07-30 13:27:20 -07:00
Chris Roberts 2628d93370 Rename method name when checking capability 2018-06-12 14:13:10 -07:00
Chris Roberts 5ba91de4d8 Use host capability to update key file permissions if available 2018-06-12 10:46:53 -07:00
Chris Roberts f0e232d739 Log error and proceed when private key permissions fail
Fixes #9765
2018-05-03 11:48:57 -07:00
Brian Cain 93356d4635
Update rm filters to test for path
This commit updates the rm filter for winrm to operate like how rm works
in bash. If a folder doesn't exist, the command returns 0 rather than 1.
2018-05-01 13:35:45 -07:00
Joe Pleso c882d888a7
Add docker cap to windows to detect daemon and fix whitespace 2018-04-27 09:45:24 -07:00
Chris Roberts 5d7506afe3
Merge pull request #9676 from chrisroberts/e-win-file-perms
Update generated ssh private key file permissions on create
2018-04-10 14:56:28 -07:00
Chris Roberts 9731720773 Update generated ssh private key file permissions on create
This updates the permissions on the automatically generated private
key file to only be readable by the user. Includes support for file
permission modification on Windows platform.
2018-04-10 14:15:14 -07:00
Chris Roberts ddfd86f3d1 Split with shellwords and quote paths in command filter
This uses shellwords to split the command in the command filter
inside the winrm communicator. Using shellwords properly handles
things like quoted paths. Path arguments are also quoted to
prevent issues with paths that include spaces.

Fixes #9390
2018-04-09 17:00:30 -07:00
Josh Soref 1a5ddea9f4 Spelling fixes
* account
* addresses
* administrator
* afterwards
* because
* bridgeable
* capabilities
* capability
* checksum
* configuration
* configuration for
* configure
* criteria
* delimited
* delivered
* derivatives
* description
* detect
* directory
* display
* downloading
* during
* electric
* enabling
* encountered
* equivalent
* executable
* executed
* hashicorp
* hypervisor
* hyphens
* implementation
* incorporate
* inheritance
* initialize
* instance
* instead
* interactions
* invocable
* machine
* maximum
* message
* mounting
* overridden
* overwrite
* paramiko
* preparing
* provides
* provisioning
* recursively
* requested
* resetting
* retryable
* running
* satisfied
* searching
* sometimes
* specified
* successfully
* synced folders
* unauthorized
* underlying
* userprofile
* vagrant
* vagrantfile
* variable
* various
* version
* virtual
* windows
2018-03-14 14:41:04 +00:00
Brian Cain c9e5a22bff (#9062) Deprecate :paranoid in favor of :verify_host_key
As of `net-ssh` version 4.2.0, the key :paranoid has been deprecated in
favor of using :verify_host_key. This commit updates Vagrants ssh config
to use the new key, and deprecates the use of :paranoid.
2018-01-05 10:02:45 -08:00
Chris Roberts eaa518159c Merge pull request #8997 from bshurts/fix/winrm-apipa
Adding check for APIPA in winrm helper to fix #8996
2017-10-23 16:47:32 -07:00
Brian Cain e1d1ba5d55 (#8974) Add Errno::EPIPE exception to ssh communicator
This commit adds an additional exception to retry ssh on when bringing
up a machine and attempting to ssh into the guest.
2017-10-17 16:44:14 -07:00
Bryce Shurts ba3c26b211 Updating winrm_info_invalid to use start_with instead of match 2017-10-05 10:28:10 -05:00
Bryce Shurts 0eaf691ea0 Adding check for APIPA in winrm helper to fix #8996 2017-09-25 16:31:37 -05:00
Brian Cain a9564b2137 (#8933) Align file provisioner functionality on all platforms
This commit aligns how the file provisioner should work on all host
machines. It ensures that a `/.` is only applied if the user intended
to upload a folder to a destination under a different name. It ensures
that if uploading to a windows guest with a different destination folder
name, it does not nest the source folder under that name so that it
works the same as it does on linux platforms. It also updates the
behavior of the winrm upload communicator by allowing an array of paths
to be uploaded instead of a single file or folder to allow for this new
functionality for windows guests.
2017-08-31 15:57:53 -07:00
Chris Roberts bcc09e10e6 Make upload directory for winssh communicator configurable
Fixes #8731
2017-07-07 11:04:37 -07:00
Brian Cain 7a97f0a53e (#6640) Use default cipher list for ssh communicator
Prior to this commit, the ssh communicator would use the default cipher
list in Net::SSH to negociate which ciphers it should use between hosts.
Due to a bug in Net::SSH and the position of the `none` cipher in its
default cipher list, if a host supported the none cipher, but also
only supported other ciphers that came after none in the default list,
it would accept none and attempt to use that cipher instead of the other
supported ciphers. This commit fixes that behavior by copying the
default cipher list from Net::SSH and placing none last in the list so
that other ciphers can be used in the negotiation before attempting to
use the unsecure none cipher.
2017-06-09 17:18:15 -07:00
Chris Roberts 62edaf5623 Allow shell to be defined when calling #execute 2017-05-05 14:04:54 -07:00
Chris Roberts 2acded113c Retry SSH connection on Errno::ECONNABORTED
In some cases the SSH connection may be aborted while waiting
for setup. This includes aborted connections in the list of
applicable exceptions to retry on while waiting for the connection
to become available.

Fixes #8520
2017-04-25 13:38:24 -07:00
Chris Roberts 067a0a5d0d communicator/ssh: Do not pass empty data to registered blocks
Prevent sending empty data strings to defined blocks handling
stderr and stdout output. These can occur when the garbage
marker is identified and collected data pruned, but no remaining
data is left to send.

Fixes #8259
2017-04-18 13:33:19 -07:00
Chris Roberts 2c9cd87a71 Remove unused configuration options 2017-04-16 08:08:22 -07:00
Chris Roberts b35c68eacc Allow sudo wrapping but default to no-op 2017-04-16 07:59:29 -07:00
Chris Roberts c56acfab94 Add WinSSH communicator 2017-04-15 07:12:58 -07:00
Chris Roberts 78e8e17869 Cast host value to string prior to empty? check.
Force string type prior to empty? check to prevent errors if
host ip value is nil. Add coverage for proper handling of nil
value.
2017-03-06 09:14:04 -08:00
Chris Roberts 6631fbdb9b Merge pull request #8073 from bshurts/fix/issue-7983
HyperV inaccurate winrm address - issue-7983
2017-03-06 09:11:34 -08:00
Chris Roberts 64fd2f71d6 communicator/ssh: discard stderr data before command run 2017-02-16 15:43:04 -08:00
Matt Wrock 725824e1dd refactor winrm communicator to use latest winrm gems and v2 api
Signed-off-by: Matt Wrock <matt@mattwrock.com>
2016-12-11 00:52:00 -08:00
Bryce Shurts e4626d088d issue-7983 - Helper now throws WinRMNotReady exception is host ip is reported as an empty string 2016-12-01 13:03:38 -06:00
Chris Roberts dfc5e0d9a0 communicator/ssh: Allow custom generation of environment variable exports 2016-11-08 09:50:39 -08:00
Chris Roberts f72cd286c1 Merge pull request #7831 from mwrock/nano
Use the cmd shell to check winrm availability to fix `vagrant up --no-provision` on nano
2016-09-30 16:16:42 -07:00
Matt Wrock c5e1a6d8c0 use the cmd shell to check winrm availability 2016-09-26 14:07:11 -07:00
Matt Wrock 64828f1ed3 fix #7489 preventing winrm connection leakage 2016-08-13 07:49:08 -07:00
Chris Roberts 155c78ea93 communicators/ssh: Filter command stdout output 2016-08-11 13:26:56 -07:00
Zack Train cb70749bd8 redux of pr 7398 for ssh-agent key fix 2016-08-11 11:48:10 -07:00