|
|
|
|
@ -13,18 +13,15 @@ import (
|
|
|
|
|
// keypair somewhere.
|
|
|
|
|
type StepDumpSSHKey struct {
|
|
|
|
|
Path string
|
|
|
|
|
SSH *SSH
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *StepDumpSSHKey) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
|
|
|
|
|
|
// Put communicator config into state so we can pass it to provisioners
|
|
|
|
|
// for specialized interpolation later
|
|
|
|
|
comm := state.Get("communicator_config").(Config)
|
|
|
|
|
|
|
|
|
|
ui.Message(fmt.Sprintf("Saving key for debug purposes: %s", s.Path))
|
|
|
|
|
|
|
|
|
|
err := ioutil.WriteFile(s.Path, comm.SSHPrivateKey, 0700)
|
|
|
|
|
err := ioutil.WriteFile(s.Path, s.SSH.SSHPrivateKey, 0700)
|
|
|
|
|
if err != nil {
|
|
|
|
|
state.Put("error", fmt.Errorf("Error saving debug key: %s", err))
|
|
|
|
|
return multistep.ActionHalt
|
|
|
|
|
|