Skip to content

Commit fb469cd

Browse files
committed
Move ssh config generation to new function
Prepare for moving into a more central place. [NO NEW TESTS NEEDED] Signed-off-by: Anders F Björklund <[email protected]>
1 parent 911a03c commit fb469cd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

pkg/machine/qemu/machine.go

+12-7
Original file line numberDiff line numberDiff line change
@@ -647,24 +647,29 @@ func (v *MachineVM) SSH(name string, opts machine.SSHOptions) error {
647647
return cmd.Run()
648648
}
649649

650-
// SSHocker does a reverse sshfs mount over a SSH connection.
651-
func (v *MachineVM) SSHocker(name string, source, target string, readonly bool) error {
652-
volumeDefinition := source + ":" + target
653-
if readonly {
654-
volumeDefinition += ":ro"
655-
}
656-
650+
func (v *MachineVM) sshConfig() string {
657651
config := fmt.Sprintf("Host %s\n", v.Name)
658652
config += fmt.Sprintf(" IdentityFile %s\n", v.IdentityPath)
659653
config += fmt.Sprintf(" User %s\n", v.RemoteUsername)
660654
config += fmt.Sprintf(" Hostname %s\n", "localhost")
661655
config += fmt.Sprintf(" Port %d\n", v.Port)
662656
config += fmt.Sprintf(" UserKnownHostsFile %s\n", "/dev/null")
663657
config += fmt.Sprintf(" StrictHostKeyChecking %s\n", "no")
658+
return config
659+
}
660+
661+
// SSHocker does a reverse sshfs mount over a SSH connection.
662+
func (v *MachineVM) SSHocker(name string, source, target string, readonly bool) error {
663+
volumeDefinition := source + ":" + target
664+
if readonly {
665+
volumeDefinition += ":ro"
666+
}
667+
664668
vmConfigDir, err := machine.GetConfDir(vmtype)
665669
if err != nil {
666670
return err
667671
}
672+
config := v.sshConfig()
668673
sshConfigFile := filepath.Join(vmConfigDir, v.Name+".config")
669674
err = ioutil.WriteFile(sshConfigFile, []byte(config), 0666)
670675
if err != nil {

0 commit comments

Comments
 (0)