Commit Graph

179 Commits

Author SHA1 Message Date
Stephen Fox d465231e63 Fixed bad curve ecdsa curve bug. 2019-02-04 14:25:37 -05:00
Stephen Fox 9328c9f9e0 Renamed "new*" SSH key pair methods. 2019-02-04 14:12:18 -05:00
Stephen Fox f8db84334d Alias 'golang.org/x/crypto/ssh' as 'gossh'. 2019-02-04 12:29:47 -05:00
Stephen Fox 9a9bc18fab Renamed SSH key pair source files per pattern.
There appears to be a pattern of naming SSH key pair related
source files "*_key_pair*".
2019-02-04 12:25:00 -05:00
Stephen Fox 7f6b307dd6 Remove 'Ssh' suffix from 'KeyPairType' constants. 2019-02-04 12:23:42 -05:00
Stephen Fox c6ae8654d9 Moved SSH key pair code into 'helper/ssh'. 2019-02-04 12:21:58 -05:00
Stephen Fox 7b857929ab Added 'SSHPublicKeyUrlEncoded()' to comm.Config.
This allows us to get a URL encoded string representing the SSH
public key. This is needed because the key will have spaces when
it is in authorized_keys format.
2019-02-03 12:14:06 -05:00
Megan Marsh c63b54a1e7 move http with proxy call into a helper function 2019-01-25 12:32:52 -08:00
Adrien Delorme b7222d1f56 Add tmp package that offers Dir & File funcs
this regroups the calls of tmp func calls into one package.
the tmp pkg allows to store tmp files under a common directory for easier managment

Squashed commit of the following:
commit 74b674c01560c6b547e9cab5e8afb486f0fe7d6c
Merge: fc94b5714 66001525d
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Fri Nov 2 02:02:38 2018 -0400

    Merge branch 'remove_TMPDIR_docs' of github.com:tb3088/packer into remove_TMPDIR_docs

commit fc94b571428447aaf2e5171967c95cdf9e5c73ff
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Fri Nov 2 01:42:38 2018 -0400

    update tests to honor configured temporary directory

commit 5a562359f4937af506607dd96ed1c46426093f52
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 18:52:38 2018 -0400

    sync straggler to refactor. implement tests at packer/configfile instead of buried in docker.

commit 9d5a4a0935bfd049e2f8f50ad73e4455b42c9410
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 15:39:46 2018 -0400

    insert URL to GoLang API for os.TempDir()

commit fbae4c2e051898aecd8705e9d8a20353430ede23
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 07:41:29 2018 -0400

    revise documentation to match code

commit 3590fae8bd0afa92a161a49ed794ee32e357d583
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 07:21:59 2018 -0400

    refacter config_file. replace all hard-coded os.TempDir with wrapper

commit d5c5306a97b648ded06a8eb76ce728f07c9924f0
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 20:11:36 2018 -0400

    close massive file overwrite hole with TempDir

commit 0a72297da86089fbd07e4f7d9472a92fa4d1c733
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 01:06:00 2018 -0400

    adjust var declaration scope

commit 20f68228b6c372d984ea5b055cfc8bda9b110ac5
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 00:54:35 2018 -0400

    use mktemp() equivalent to create temporary directory

commit c73ebe3d8321664a2685a0baa8e441dd895b0db4
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 20:40:58 2018 -0400

    remove extraneous variable declaration, fix FOR loop

commit 63549b8bd745a0090b15ed0b0ebf644162db27db
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 19:30:44 2018 -0400

    match styistic convension with rest of docs

commit 976101074942db36f10d3a686d6d29ddb7c01926
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 19:08:39 2018 -0400

    revert dangling config file change

commit 95159afbc05eac96ed11c3183af5fb0abe2f2d5c
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Fri Dec 29 23:53:43 2017 -0500

    replace invalid TMPDIR variable wth PACKER_TMP_DIR.
    update ConfigTmpDir() to try common temporary paths first and
    only write to configDir() as a last resort.

commit 66001525d72de56a4cf9339b900c46f59bc6e91a
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Fri Nov 2 01:42:38 2018 -0400

    update tests to honor configured temporary directory

commit e9b6adefeae8c65eb8aa47fef38cbf0aa424338c
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 18:52:38 2018 -0400

    sync straggler to refactor. implement tests at packer/configfile instead of buried in docker.

commit 852113ed076e2d14e5dca6815ea680da1e2896bb
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 15:39:46 2018 -0400

    insert URL to GoLang API for os.TempDir()

commit 54add38d1d1c6e283cd444b367ed8bd49a5f3699
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 07:41:29 2018 -0400

    revise documentation to match code

commit 6b5b8f6d4edad0e187ca13d64ac4118f34eee643
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 07:21:59 2018 -0400

    refacter config_file. replace all hard-coded os.TempDir with wrapper

commit c22092c601c33484327674f322c7379fa41506d7
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 20:11:36 2018 -0400

    close massive file overwrite hole with TempDir

commit 7a730450916bf8e5dbc2a741ec233a49466ab7cc
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 01:06:00 2018 -0400

    adjust var declaration scope

commit 0f2933adb6f6922dfeab78a95371a444ec8918ab
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 00:54:35 2018 -0400

    use mktemp() equivalent to create temporary directory

commit d74839ede05dacf712b55a7bb48aec19fe6b007f
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 20:40:58 2018 -0400

    remove extraneous variable declaration, fix FOR loop

commit eb65416619437e4a3dec90277770803dd5b2281c
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 19:30:44 2018 -0400

    match styistic convension with rest of docs

commit acaa2b31ed463219c4ef099f351eec72406e2989
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 19:08:39 2018 -0400

    revert dangling config file change

commit e573fde668dcb418561e61535c1d68b2888f5b0f
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Fri Dec 29 23:53:43 2017 -0500

    replace invalid TMPDIR variable wth PACKER_TMP_DIR.
    update ConfigTmpDir() to try common temporary paths first and
    only write to configDir() as a last resort.

commit 39a9874afc9dea71b36753375fb7feb61ffecf69
Merge: 8a413cfe8 3315812c2
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 18:19:26 2018 -0400

    Merge branch 'master' of https://github.com/hashicorp/packer into prestine

commit 8a413cfe83b0a70dbd99c32d936334ca5788ca9b
Merge: e07491de5 4e14710a6
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Mon Oct 1 20:18:10 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit e07491de59cead0b337a7f57f4a6c625e1f560ab
Merge: 42610a35d a1fa35dff
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Aug 21 13:26:19 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit 42610a35d5ef65af8844a58ad70e2ec75262da6a
Merge: 5298142da 0d63cf7bc
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Tue Jun 19 22:45:05 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit 5298142da6da95354844f201deeeef3c599e48b2
Merge: 7bb110bc7 9d9736552
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Mon Jun 11 15:10:09 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit 7bb110bc744c9797fcaec25a265d9b85a22d6d6b
Merge: a61c869ca 6189d66e7
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Wed May 9 23:41:22 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit a61c869ca7268acf0e3b1e1fa7a8ee7feea65984
Merge: 098101dd9 4be5f072c
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Fri May 4 10:13:04 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit 098101dd99f08b0ca110d33eff6904537c6d21de
Merge: fefaf0fa6 554b2b4a5
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Tue May 1 20:52:30 2018 -0400

    Merge branch 'EOL-handling' into prestine

Co-Authored-By: Matthew Patton <pattonme@yahoo.com>
2018-12-12 16:35:57 +01:00
Ali Rizvi-Santiago b0af406e08 gofmt using v1.11.2 instead of disro's outdated v1.10.5. 2018-12-04 16:54:49 -06:00
Ali Rizvi-Santiago 040a33567e Trying again one more time to prevent import cycles.. Moved common.ExpandUser into packer.ExpandUser.. 2018-12-04 16:54:47 -06:00
Ali Rizvi-Santiago 79b68fb89c Replaced the previous incorrect logic with an re-implementation of common.ExpandUser. 2018-12-04 16:53:33 -06:00
Ali Rizvi-Santiago e04986659a Changed the logic for when to actually prefix a path with a u.HomeDir so that it's only done when a non-absolute path is specified. 2018-12-04 16:53:33 -06:00
Ali Rizvi-Santiago 1a3c3f2ffc Replaced all instances of mitchellh/go-homedir with an implementation based on os/user. 2018-12-04 16:53:33 -06:00
Mikhail Ushanov ee0bff6451 communicator/ssh: proper error message
Signed-off-by: Mikhail Ushanov <gm.mephisto@gmail.com>
2018-11-08 14:25:50 +03:00
Mikhail Ushanov 45925657fc communicator/ssh: make ssh keys payload internal
Signed-off-by: Mikhail Ushanov <gm.mephisto@gmail.com>
2018-11-08 14:25:50 +03:00
Mikhail Ushanov 1c503b86d9 communicator/ssh: expand user path for bastion private key
Signed-off-by: Mikhail Ushanov <gm.mephisto@gmail.com>
2018-11-08 14:25:50 +03:00
Mikhail Ushanov 6d2a0ab0df communicator/ssh: expand user path for private key
Signed-off-by: Mikhail Ushanov <gm.mephisto@gmail.com>
2018-11-08 14:25:50 +03:00
Mikhail Ushanov da0bad8441 communicator/ssh: add private key file read helper
Signed-off-by: Mikhail Ushanov <gm.mephisto@gmail.com>
2018-11-08 14:25:50 +03:00
Megan Marsh 38cc525ec7 new option allowing user to clean up the ephemeral ssh key from the authorized_keys file 2018-09-14 11:06:38 -07:00
Adrien Delorme b0c09087a2 move SSHInterface/SSHIPVersion fields to communitator.Config struct 2018-08-29 14:51:28 +02:00
Adrien Delorme 1d219cecaf add SSHTemporaryKeyPairName to communicator.Config 2018-08-29 14:40:33 +02:00
Adrien Delorme 9a9b82715b config.Comm.SSHKeyPair => SSHKeyPairName 2018-08-29 14:40:33 +02:00
Adrien Delorme 77a57f0354 communicator.Config: `mapstructure:"ssh_key_pair"` => ssh_keypair_name 2018-08-29 14:40:33 +02:00
Adrien Delorme 69dfe2565b SSHBastionPrivateKey => SSHBastionPrivateKeyFile 2018-08-29 14:40:33 +02:00
Adrien Delorme 5369c15459 helper: communicator.SSHFileSigner => ssh.FileSigner
* had to to avoid circular dependency
* this commit fixes #6631 ( esxi cannot be reached by ssh )
2018-08-29 14:40:33 +02:00
Adrien Delorme b83c72fd54 more private keys in config 2018-08-29 14:40:32 +02:00
Adrien Delorme 663c8134ef GCP: put ssh public/private key in config 2018-08-29 14:40:32 +02:00
Adrien Delorme 51d2aac9f6 SSHPrivateKey => SSHPrivateKeyFile 2018-08-29 14:40:32 +02:00
Matthew Hooker e41e99954d
go 1.11 format rules 2018-08-24 15:56:44 -07:00
Megan Marsh 340363a649
Merge pull request #6613 from hashicorp/merge_ssh_config_funcs
Merge ssh config funcs from builders
2018-08-23 16:03:36 -07:00
Adrien Delorme fa44a4546f use ssh.ParsePrivateKey where we can 2018-08-22 18:23:09 +02:00
Adrien Delorme bacfb02182 doc better SSHConfigFunc 2018-08-22 18:16:25 +02:00
Adrien Delorme ab7f998862 SSHConfigFunc: use struct fields instead of copying them locally 2018-08-22 17:08:46 +02:00
Adrien Delorme 0ff7c1da87 SSHConfigFunc: append the ssh auth ways 2018-08-22 17:03:25 +02:00
Adrien Delorme 41f6e0334d refactor all copy pasted sshConfig with into communicator.Config.SSHConfigFunc
* still need to append the auth methods into an array for gracefullness
2018-08-22 17:02:23 +02:00
Megan Marsh ff6a039d5b replace scrubconfig with packer.LogSecretFilter.Set
filter winrm password from logs
Add new root-level packer template option, sensitive-variables, to tell us what user variables to mark sensitive.
2018-08-20 15:35:55 -07:00
Ali Rizvi-Santiago a3cec4f274 Emit both the host and the communicator to the user during StepConnect. 2018-07-29 02:18:26 -05:00
Megan Marsh 3afb243f11 use build name to ensure that winrm password and other shared state is not overwritten if two builders need the password in the same packer run. 2018-04-16 13:41:17 -07:00
Seth Vargo b193b96f76
Include arch and os 2018-04-05 14:28:50 -04:00
Seth Vargo b17b333e29
Add a common package for specifying useragent and adopt that everywhere
There were 5 different formats for the Packer useragent string. This
fixes that and unifies it into a helper package.

I did not touch oracle's user-agent, because it looked kinda special.
2018-04-05 14:28:50 -04:00
Megan Marsh 4e32d0da24 stricter permissions on shared state file since it now contains a password 2018-03-16 14:11:32 -07:00
Megan Marsh 4d19f4f8b6 add all the new files 2018-03-14 15:58:12 -07:00
Josh Soref 64aae1c781 spelling: occurring 2018-03-13 08:16:48 +00:00
Josh Soref 5e167e3b6d spelling: accumulates 2018-03-13 07:03:51 +00:00
SwampDragons 5af42ee9e2
Revert "Add `winrm_no_proxy` option." 2018-02-08 15:10:53 -08:00
Matthew Hooker 22666153f9
Add `winrm_no_proxy` option.
Setting this adds the remote host:ip to the `NO_PROXY` environment
variable.
2018-02-07 20:58:08 -08:00
Matthew Hooker 63f1673909
ssh deadlines 2018-01-31 12:35:25 -08:00
Matthew Hooker cab52872f4
add session level keep-alives for ssh communicator 2018-01-30 22:00:37 -08:00
Matthew Hooker 3e2895afec
comments 2018-01-24 17:09:18 -08:00
Matthew Hooker 2afd81741c
use correct context 2018-01-24 17:09:18 -08:00
Matthew Hooker ce4f30c5ae
fix tests 2018-01-24 17:09:17 -08:00
Matthew Hooker 8cd403425e
test fixes WIP 2018-01-24 17:09:17 -08:00
Matthew Hooker 5d48d658b4
Wire context through misc steps
Some steps actually need to pass the context around, so let's create
a ctx variable and pass it.
2018-01-24 17:09:17 -08:00
Matthew Hooker 7a189a83a1
fix imports
`find . -type f -name '*.go' -not -path "./vendor/*" -exec goimports -w {} \;`
2018-01-24 17:09:17 -08:00
Matthew Hooker a831d522be
change run signatures
Run now takes a context as well as a statebag. We'll assign the context
to the blank identifier to prevent namespace collisions. We'll let the
step authors opt-in to using the context.

`find . -iname "step_*.go" -exec gsed -i'' 's/func \(.*\)Run(/func \1Run(_ context.Context, /' {} \;`
2018-01-24 17:09:17 -08:00
Matthew Hooker a0c625ea44
Revert "working with opt-in"
This reverts commit 4068ffdaf541354e75507add7ca0b193993fcd52.
2018-01-24 17:09:16 -08:00
Matthew Hooker e98f201602
working with opt-in 2018-01-24 17:09:16 -08:00
Matthew Hooker 62e3d1362f
pass context through step.run again 2018-01-24 17:09:16 -08:00
Matthew Hooker 030b5fd4f0
WIP add context to state bag 2018-01-24 17:09:16 -08:00
Matthew Hooker 07a5af66f8
remove ctx arg from step.run 2018-01-24 17:09:15 -08:00
Matthew Hooker 366dc3da0a
move multistep imports to helper.
gomvpkg -from "github.com/mitchellh/multistep" -to "github.com/hashicorp/packer/helper/multistep"
2018-01-24 17:09:15 -08:00
Matthew Hooker 89d43256bb
pass context into step.run 2018-01-24 17:09:15 -08:00
Matthew Hooker 807e88245b
trying to add context to state bag 2018-01-24 17:09:15 -08:00
Pawel Kilar 17beb1d7ad Check if both SSH proxy and basiton are configured 2017-10-14 21:38:44 +01:00
Paul Kilar d9b404fa00 SOCKS5 proxy support 2017-10-10 15:04:15 +01:00
Megan Marsh 959db1ac16 add echo test to winrm connection. 2017-09-01 15:26:41 -07:00
Rickard von Essen 4f6010aa26
ssh: Renamed ssh_disable_agent to ssh_disable_agent_forwarding
Closes: #4941
2017-06-19 16:26:18 +02:00
Lee Spottiswood 8473a1148c Add 'winrm_use_ntlm' configuration directive for NTLM authentication support 2017-06-07 12:08:12 +01:00
Rickard von Essen d4ecf4acb3
Add InsecureIgnoreHostKey to bastion connection 2017-05-28 20:35:01 +02:00
Rickard von Essen 2164700162
comm/ssh: Add support for using SSH Agent auth towards a bastion host.
Adds `ssh_bastion_agent_auth`

Fixes: #4732
2017-05-28 14:05:03 +02:00
Matthew Hooker 81522dced0
move packer to hashicorp 2017-04-04 13:39:01 -07:00
Matthew Hooker aaba5286a6 Revert "Use SSH agent when enabled for bastion step" 2017-02-27 11:30:08 -08:00
David Campbell 6c7e3b70a9
- use xanzy/ssh-agent for windows compatibility 2017-02-26 18:01:45 -08:00
David Campbell b598baa5e3
Use SSH agent when enabled for bastion step 2017-02-26 17:59:42 -08:00
Eike Verdenhalven 7ad77b9e93 integrate new winrm transport interface 2017-01-18 22:11:48 +01:00
Taliesin Sisson 335615408a Run go fmt on files 2016-12-12 22:45:19 +00:00
Taliesin Sisson bd0b1190f6 When redirecting local ports to hyper visor ports we need to configure WinRM ports as well as SSH ports. 2016-12-12 22:44:09 +00:00
Rickard von Essen 96e9a8e6e9 Removed default value for ssh_username 2016-11-17 22:30:34 +01:00
James Nugent 7425fef2c7 builder/amazon: Allow use of local SSH Agent
This commit adds an option to use the local SSH Agent to authenticate
connections to source instances started by the the EBS and Instance
Store builders.

This is of use when the source AMI _already_ has configuration for
authorized SSH keys - for example if one uses an SSH certificate
authority.

A further extension (not implemented in this commit) is to allow SSH
agent use with a pre-defined key pair, in order to allow keys with
passphrases to be used without giving the passphrase to Packer.
2016-10-23 21:43:47 -05:00
Orivej Desh 639bf356aa Fail on unknown values of -on-error 2016-09-17 14:42:21 +00:00
Gonzalo Peci 9c9f8cd451 Add winrm functionality to null provisioner (#2525)
* Add new functions to communicator helper to return the user, password, host, based on the communicator used.

This implementation can help then generalize the provisioeners later on.

* Update null builder checks to utilize the new functions and check for ANY hostname or user or password

* Update builder to user any hostname
2016-05-18 17:22:53 -07:00
Christopher Boumenot b57ed27352 Add support for NTLM the WinRM communicator.
WinRM exposes an HTTP transport decorator that can be used for different
authentication schemes.  Windows on Azures requires this if one is to use
the out of the box configuration.
2016-03-10 10:53:38 -08:00
Ilias Bertsimas 918c88ac38 Add 4 testing scenarios for WinRM helper communicator config. 2016-03-02 11:48:20 +00:00
Ilias Bertsimas 85e4865368 Make communicator's WinRM defaults more intuitive when using SSL. 2016-02-29 14:26:28 +00:00
Chris Bednarski 569e6cc464 go fmt 2016-02-08 17:34:06 -08:00
Chris Bednarski 3d9410f176 Merge branch 'sftp' of https://github.com/2opremio/packer into f-sftp 2016-02-02 14:16:19 -08:00
Chris Bednarski 6587926a2b Merge pull request #2848 from epowell/master
Implement a null-object communicator for 'none'
2016-01-21 12:44:36 -08:00
Ben Goodwin 64152e4a64 Implement WinRM-over-HTTPS 2016-01-12 21:28:20 -05:00
Evan Powell bb8ced8cc9 Implement a null-object communicator for 'none'
Fixes #2736
2015-10-20 17:00:48 -05:00
Mark Peek 268ce81dd3 helper/communicator: allow docker custom communicator 2015-10-11 11:48:16 -07:00
Mark Peek 2306f4a4e4 Fixes #2699: catch invalid communicator types 2015-10-11 11:20:50 -07:00
Alfonso Acosta a59c82d7a6 Add sftp file transfer support
Adds a new config option: "ssh_file_transfer_method", which can be set to "scp"
or "sftp" (defaults to "scp")
2015-07-26 23:49:18 +00:00
Gonzalo Peci 88ebc2f7e8 Add s.SSHPort variable as the port WinRM uses to connect. This is needed on any builder where the port used to connect is not the guest winrm port but a nated port on the host.
Similar behavior is used by the SSH communicator.
2015-07-27 09:57:38 +12:00
Chris Bednarski 7a6eb966c0 We actually use PACKER_ACC not TF_ACC 2015-07-24 14:49:44 -07:00
Mitchell Hashimoto ac444accb1 helper/config: tests 2015-06-30 10:44:56 -07:00
Mitchell Hashimoto fd2d44c212 helper/config: copy buildname/buildtype properly 2015-06-30 10:42:55 -07:00
Chris Bednarski eee066371a Support -flag=var1,var2,var3 to fix #2332 2015-06-26 17:54:59 -07:00
Mitchell Hashimoto a019575026 helper/communicator: support disabling SSH agent 2015-06-23 14:52:37 -07:00
Mitchell Hashimoto 6cdc17dda4 helper/communicator: default bastion PK to normal PK 2015-06-17 22:33:59 +02:00