Skip to content

Commit 8900ebf

Browse files
committed
Add SSH address for supplying external IP
Verify ssh host keys, when connecting to a remote server. The first connection will prompt, if not in known_hosts. Print IP instead of Port (when it is 22) for non-local SSH. The field is still called LocalPort, even if is now remote. Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
1 parent 0cb9389 commit 8900ebf

File tree

21 files changed

+133
-50
lines changed

21 files changed

+133
-50
lines changed

cmd/limactl/copy.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func checkRsyncOnGuest(ctx context.Context, inst *limatype.Instance) bool {
257257
logrus.Debugf("failed to create SSH executable: %v", err)
258258
return false
259259
}
260-
sshOpts, err := sshutil.SSHOpts(ctx, sshExe, inst.Dir, *inst.Config.User.Name, false, false, false, false)
260+
sshOpts, err := sshutil.SSHOpts(ctx, sshExe, inst.Dir, *inst.Config.User.Name, false, inst.SSHAddress, false, false, false)
261261
if err != nil {
262262
logrus.Debugf("failed to get SSH options for rsync check: %v", err)
263263
return false
@@ -268,7 +268,7 @@ func checkRsyncOnGuest(ctx context.Context, inst *limatype.Instance) bool {
268268
checkCmd.Args = append(checkCmd.Args, sshArgs...)
269269
checkCmd.Args = append(checkCmd.Args,
270270
"-p", fmt.Sprintf("%d", inst.SSHLocalPort),
271-
fmt.Sprintf("%s@127.0.0.1", *inst.Config.User.Name),
271+
fmt.Sprintf("%s@%s", *inst.Config.User.Name, inst.SSHAddress),
272272
"command -v rsync >/dev/null 2>&1",
273273
)
274274

@@ -297,14 +297,18 @@ func scpCommand(ctx context.Context, command string, copyPaths []*copyPath, verb
297297
return nil, err
298298
}
299299
legacySSH := sshutil.DetectOpenSSHVersion(ctx, sshExeForVersion).LessThan(*semver.New("8.0.0"))
300+
localhostOnly := true
300301

301302
for _, cp := range copyPaths {
302303
if cp.isRemote {
303304
if legacySSH {
304305
scpFlags = append(scpFlags, "-P", fmt.Sprintf("%d", cp.instance.SSHLocalPort))
305-
scpArgs = append(scpArgs, fmt.Sprintf("%s@127.0.0.1:%s", *cp.instance.Config.User.Name, cp.path))
306+
scpArgs = append(scpArgs, fmt.Sprintf("%s@%s:%s", *cp.instance.Config.User.Name, cp.instance.SSHAddress, cp.path))
306307
} else {
307-
scpArgs = append(scpArgs, fmt.Sprintf("scp://%s@127.0.0.1:%d/%s", *cp.instance.Config.User.Name, cp.instance.SSHLocalPort, cp.path))
308+
scpArgs = append(scpArgs, fmt.Sprintf("scp://%s@%s:%d/%s", *cp.instance.Config.User.Name, cp.instance.SSHAddress, cp.instance.SSHLocalPort, cp.path))
309+
}
310+
if !sshutil.IsLocalhost(cp.instance.SSHAddress) {
311+
localhostOnly = false
308312
}
309313
instances[cp.instanceName] = cp.instance
310314
} else {
@@ -329,7 +333,7 @@ func scpCommand(ctx context.Context, command string, copyPaths []*copyPath, verb
329333
if err != nil {
330334
return nil, err
331335
}
332-
sshOpts, err = sshutil.SSHOpts(ctx, sshExe, inst.Dir, *inst.Config.User.Name, false, false, false, false)
336+
sshOpts, err = sshutil.SSHOpts(ctx, sshExe, inst.Dir, *inst.Config.User.Name, false, inst.SSHAddress, false, false, false)
333337
if err != nil {
334338
return nil, err
335339
}
@@ -340,7 +344,7 @@ func scpCommand(ctx context.Context, command string, copyPaths []*copyPath, verb
340344
if err != nil {
341345
return nil, err
342346
}
343-
sshOpts, err = sshutil.CommonOpts(ctx, sshExe, false)
347+
sshOpts, err = sshutil.CommonOpts(ctx, sshExe, false, localhostOnly)
344348
if err != nil {
345349
return nil, err
346350
}
@@ -377,7 +381,7 @@ func rsyncCommand(ctx context.Context, command string, copyPaths []*copyPath, ve
377381
if err != nil {
378382
return nil, err
379383
}
380-
sshOpts, err := sshutil.SSHOpts(ctx, sshExe, cp.instance.Dir, *cp.instance.Config.User.Name, false, false, false, false)
384+
sshOpts, err := sshutil.SSHOpts(ctx, sshExe, cp.instance.Dir, *cp.instance.Config.User.Name, false, cp.instance.SSHAddress, false, false, false)
381385
if err != nil {
382386
return nil, err
383387
}
@@ -394,7 +398,7 @@ func rsyncCommand(ctx context.Context, command string, copyPaths []*copyPath, ve
394398

395399
for _, cp := range copyPaths {
396400
if cp.isRemote {
397-
rsyncArgs = append(rsyncArgs, fmt.Sprintf("%s@127.0.0.1:%s", *cp.instance.Config.User.Name, cp.path))
401+
rsyncArgs = append(rsyncArgs, fmt.Sprintf("%s@%s:%s", *cp.instance.Config.User.Name, cp.instance.SSHAddress, cp.path))
398402
} else {
399403
rsyncArgs = append(rsyncArgs, cp.path)
400404
}

cmd/limactl/shell.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ func shellAction(cmd *cobra.Command, args []string) error {
230230
inst.Dir,
231231
*inst.Config.User.Name,
232232
*inst.Config.SSH.LoadDotSSHPubKeys,
233+
*inst.Config.SSH.Address,
233234
*inst.Config.SSH.ForwardAgent,
234235
*inst.Config.SSH.ForwardX11,
235236
*inst.Config.SSH.ForwardX11Trusted)

cmd/limactl/show-ssh.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,14 @@ func showSSHAction(cmd *cobra.Command, args []string) error {
103103
inst.Dir,
104104
*inst.Config.User.Name,
105105
*inst.Config.SSH.LoadDotSSHPubKeys,
106+
*inst.Config.SSH.Address,
106107
*inst.Config.SSH.ForwardAgent,
107108
*inst.Config.SSH.ForwardX11,
108109
*inst.Config.SSH.ForwardX11Trusted)
109110
if err != nil {
110111
return err
111112
}
112-
opts = append(opts, "Hostname=127.0.0.1")
113+
opts = append(opts, fmt.Sprintf("Hostname=%s", inst.SSHAddress))
113114
opts = append(opts, fmt.Sprintf("Port=%d", inst.SSHLocalPort))
114115
return sshutil.Format(w, "ssh", instName, format, opts)
115116
}

cmd/limactl/tunnel.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func tunnelAction(cmd *cobra.Command, args []string) error {
9595
inst.Dir,
9696
*inst.Config.User.Name,
9797
*inst.Config.SSH.LoadDotSSHPubKeys,
98+
*inst.Config.SSH.Address,
9899
*inst.Config.SSH.ForwardAgent,
99100
*inst.Config.SSH.ForwardX11,
100101
*inst.Config.SSH.ForwardX11Trusted)

pkg/cidata/cidata.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ import (
3838
)
3939

4040
var netLookupIP = func(host string) []net.IP {
41-
ips, err := net.LookupIP(host)
41+
ctx := context.Background()
42+
ips, err := net.DefaultResolver.LookupIP(ctx, "ip", host)
4243
if err != nil {
4344
logrus.Debugf("net.LookupIP %s: %s", host, err)
4445
return nil

pkg/hostagent/events/events.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ type Status struct {
1616

1717
Errors []string `json:"errors,omitempty"`
1818

19-
SSHLocalPort int `json:"sshLocalPort,omitempty"`
19+
SSHIPAddress string `json:"sshIPAddress,omitempty"`
20+
SSHLocalPort int `json:"sshLocalPort,omitempty"`
2021

2122
// Cloud-init progress information
2223
CloudInitProgress *CloudInitProgress `json:"cloudInitProgress,omitempty"`

pkg/hostagent/hostagent.go

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func New(ctx context.Context, instName string, stdout io.Writer, signalCh chan o
137137
}
138138

139139
// inst.Config is loaded with FillDefault() already, so no need to care about nil pointers.
140-
sshLocalPort, err := determineSSHLocalPort(*inst.Config.SSH.LocalPort, instName, limaVersion)
140+
sshLocalPort, err := determineSSHLocalPort(*inst.Config.SSH.Address, *inst.Config.SSH.LocalPort, instName, limaVersion)
141141
if err != nil {
142142
return nil, err
143143
}
@@ -189,6 +189,7 @@ func New(ctx context.Context, instName string, stdout io.Writer, signalCh chan o
189189
inst.Dir,
190190
*inst.Config.User.Name,
191191
*inst.Config.SSH.LoadDotSSHPubKeys,
192+
*inst.Config.SSH.Address,
192193
*inst.Config.SSH.ForwardAgent,
193194
*inst.Config.SSH.ForwardX11,
194195
*inst.Config.SSH.ForwardX11Trusted)
@@ -244,7 +245,7 @@ func New(ctx context.Context, instName string, stdout io.Writer, signalCh chan o
244245
instName: instName,
245246
instSSHAddress: inst.SSHAddress,
246247
sshConfig: sshConfig,
247-
portForwarder: newPortForwarder(sshConfig, sshLocalPort, rules, ignoreTCP, inst.VMType),
248+
portForwarder: newPortForwarder(sshConfig, inst.SSHAddress, sshLocalPort, rules, ignoreTCP, inst.VMType),
248249
grpcPortForwarder: portfwd.NewPortForwarder(rules, ignoreTCP, ignoreUDP),
249250
driver: limaDriver,
250251
signalCh: signalCh,
@@ -290,13 +291,16 @@ func writeSSHConfigFile(sshPath, instName, instDir, instSSHAddress string, sshLo
290291
return os.WriteFile(fileName, b.Bytes(), 0o600)
291292
}
292293

293-
func determineSSHLocalPort(confLocalPort int, instName, limaVersion string) (int, error) {
294+
func determineSSHLocalPort(confSSHAddress string, confLocalPort int, instName, limaVersion string) (int, error) {
294295
if confLocalPort > 0 {
295296
return confLocalPort, nil
296297
}
297298
if confLocalPort < 0 {
298299
return 0, fmt.Errorf("invalid ssh local port %d", confLocalPort)
299300
}
301+
if confLocalPort == 0 && confSSHAddress != "127.0.0.1" {
302+
return 22, nil
303+
}
300304
if versionutil.LessThan(limaVersion, "2.0.0") && instName == "default" {
301305
// use hard-coded value for "default" instance, for backward compatibility
302306
return 60022, nil
@@ -445,8 +449,22 @@ func (a *HostAgent) Run(ctx context.Context) error {
445449
return a.startRoutinesAndWait(ctx, errCh)
446450
}
447451

452+
func getIP(address string) string {
453+
ip := net.ParseIP(address)
454+
if ip != nil {
455+
return address
456+
}
457+
ctx := context.Background()
458+
ips, err := net.DefaultResolver.LookupIP(ctx, "ip", address)
459+
if err == nil && len(ips) > 0 {
460+
return ips[0].String()
461+
}
462+
return address
463+
}
464+
448465
func (a *HostAgent) startRoutinesAndWait(ctx context.Context, errCh <-chan error) error {
449466
stBase := events.Status{
467+
SSHIPAddress: getIP(a.instSSHAddress),
450468
SSHLocalPort: a.sshLocalPort,
451469
}
452470
stBooting := stBase
@@ -639,7 +657,7 @@ func (a *HostAgent) watchGuestAgentEvents(ctx context.Context) {
639657
for _, rule := range a.instConfig.PortForwards {
640658
if rule.GuestSocket != "" {
641659
local := hostAddress(rule, &guestagentapi.IPPort{})
642-
_ = forwardSSH(ctx, a.sshConfig, a.sshLocalPort, local, rule.GuestSocket, verbForward, rule.Reverse)
660+
_ = forwardSSH(ctx, a.sshConfig, a.instSSHAddress, a.sshLocalPort, local, rule.GuestSocket, verbForward, rule.Reverse)
643661
}
644662
}
645663
}
@@ -654,13 +672,13 @@ func (a *HostAgent) watchGuestAgentEvents(ctx context.Context) {
654672
if rule.GuestSocket != "" {
655673
local := hostAddress(rule, &guestagentapi.IPPort{})
656674
// using ctx.Background() because ctx has already been cancelled
657-
if err := forwardSSH(context.Background(), a.sshConfig, a.sshLocalPort, local, rule.GuestSocket, verbCancel, rule.Reverse); err != nil {
675+
if err := forwardSSH(context.Background(), a.sshConfig, a.instSSHAddress, a.sshLocalPort, local, rule.GuestSocket, verbCancel, rule.Reverse); err != nil {
658676
errs = append(errs, err)
659677
}
660678
}
661679
}
662680
if a.driver.ForwardGuestAgent() {
663-
if err := forwardSSH(context.Background(), a.sshConfig, a.sshLocalPort, localUnix, remoteUnix, verbCancel, false); err != nil {
681+
if err := forwardSSH(context.Background(), a.sshConfig, a.instSSHAddress, a.sshLocalPort, localUnix, remoteUnix, verbCancel, false); err != nil {
664682
errs = append(errs, err)
665683
}
666684
}
@@ -671,7 +689,7 @@ func (a *HostAgent) watchGuestAgentEvents(ctx context.Context) {
671689
if a.instConfig.MountInotify != nil && *a.instConfig.MountInotify {
672690
if a.client == nil || !isGuestAgentSocketAccessible(ctx, a.client) {
673691
if a.driver.ForwardGuestAgent() {
674-
_ = forwardSSH(ctx, a.sshConfig, a.sshLocalPort, localUnix, remoteUnix, verbForward, false)
692+
_ = forwardSSH(ctx, a.sshConfig, a.instSSHAddress, a.sshLocalPort, localUnix, remoteUnix, verbForward, false)
675693
}
676694
}
677695
err := a.startInotify(ctx)
@@ -687,7 +705,7 @@ func (a *HostAgent) watchGuestAgentEvents(ctx context.Context) {
687705
for {
688706
if a.client == nil || !isGuestAgentSocketAccessible(ctx, a.client) {
689707
if a.driver.ForwardGuestAgent() {
690-
_ = forwardSSH(ctx, a.sshConfig, a.sshLocalPort, localUnix, remoteUnix, verbForward, false)
708+
_ = forwardSSH(ctx, a.sshConfig, a.instSSHAddress, a.sshLocalPort, localUnix, remoteUnix, verbForward, false)
691709
}
692710
}
693711
client, err := a.getOrCreateClient(ctx)
@@ -721,7 +739,7 @@ func (a *HostAgent) addStaticPortForwardsFromList(ctx context.Context, staticPor
721739
local, remote := a.portForwarder.forwardingAddresses(guest)
722740
if local != "" {
723741
logrus.Infof("Setting up static TCP forwarding from %s to %s", remote, local)
724-
if err := forwardTCP(ctx, a.sshConfig, a.sshLocalPort, local, remote, verbForward); err != nil {
742+
if err := forwardTCP(ctx, a.sshConfig, a.instSSHAddress, a.sshLocalPort, local, remote, verbForward); err != nil {
725743
logrus.WithError(err).Warnf("failed to set up static TCP forwarding %s -> %s", remote, local)
726744
}
727745
}
@@ -831,11 +849,11 @@ const (
831849
verbCancel = "cancel"
832850
)
833851

834-
func executeSSH(ctx context.Context, sshConfig *ssh.SSHConfig, port int, command ...string) error {
852+
func executeSSH(ctx context.Context, sshConfig *ssh.SSHConfig, addr string, port int, command ...string) error {
835853
args := sshConfig.Args()
836854
args = append(args,
837855
"-p", strconv.Itoa(port),
838-
"127.0.0.1",
856+
addr,
839857
"--",
840858
)
841859
args = append(args, command...)
@@ -846,7 +864,7 @@ func executeSSH(ctx context.Context, sshConfig *ssh.SSHConfig, port int, command
846864
return nil
847865
}
848866

849-
func forwardSSH(ctx context.Context, sshConfig *ssh.SSHConfig, port int, local, remote, verb string, reverse bool) error {
867+
func forwardSSH(ctx context.Context, sshConfig *ssh.SSHConfig, addr string, port int, local, remote, verb string, reverse bool) error {
850868
args := sshConfig.Args()
851869
args = append(args,
852870
"-T",
@@ -865,15 +883,15 @@ func forwardSSH(ctx context.Context, sshConfig *ssh.SSHConfig, port int, local,
865883
"-N",
866884
"-f",
867885
"-p", strconv.Itoa(port),
868-
"127.0.0.1",
886+
addr,
869887
"--",
870888
)
871889
if strings.HasPrefix(local, "/") {
872890
switch verb {
873891
case verbForward:
874892
if reverse {
875893
logrus.Infof("Forwarding %q (host) to %q (guest)", local, remote)
876-
if err := executeSSH(ctx, sshConfig, port, "rm", "-f", remote); err != nil {
894+
if err := executeSSH(ctx, sshConfig, addr, port, "rm", "-f", remote); err != nil {
877895
logrus.WithError(err).Warnf("Failed to clean up %q (guest) before setting up forwarding", remote)
878896
}
879897
} else {
@@ -888,7 +906,7 @@ func forwardSSH(ctx context.Context, sshConfig *ssh.SSHConfig, port int, local,
888906
case verbCancel:
889907
if reverse {
890908
logrus.Infof("Stopping forwarding %q (host) to %q (guest)", local, remote)
891-
if err := executeSSH(ctx, sshConfig, port, "rm", "-f", remote); err != nil {
909+
if err := executeSSH(ctx, sshConfig, addr, port, "rm", "-f", remote); err != nil {
892910
logrus.WithError(err).Warnf("Failed to clean up %q (guest) after stopping forwarding", remote)
893911
}
894912
} else {
@@ -909,7 +927,7 @@ func forwardSSH(ctx context.Context, sshConfig *ssh.SSHConfig, port int, local,
909927
if verb == verbForward && strings.HasPrefix(local, "/") {
910928
if reverse {
911929
logrus.WithError(err).Warnf("Failed to set up forward from %q (host) to %q (guest)", local, remote)
912-
if err := executeSSH(ctx, sshConfig, port, "rm", "-f", remote); err != nil {
930+
if err := executeSSH(ctx, sshConfig, addr, port, "rm", "-f", remote); err != nil {
913931
logrus.WithError(err).Warnf("Failed to clean up %q (guest) after forwarding failed", remote)
914932
}
915933
} else {

pkg/hostagent/mount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (a *HostAgent) setupMount(ctx context.Context, m limatype.Mount) (*mount, e
6565
Driver: *m.SSHFS.SFTPDriver,
6666
SSHConfig: a.sshConfig,
6767
LocalPath: resolvedLocation,
68-
Host: "127.0.0.1",
68+
Host: a.instSSHAddress,
6969
Port: a.sshLocalPort,
7070
RemotePath: *m.MountPoint,
7171
Readonly: !(*m.Writable),

pkg/hostagent/port.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
type portForwarder struct {
1919
sshConfig *ssh.SSHConfig
20+
sshHostAddr string
2021
sshHostPort int
2122
rules []limatype.PortForward
2223
ignore bool
@@ -27,9 +28,10 @@ const sshGuestPort = 22
2728

2829
var IPv4loopback1 = limayaml.IPv4loopback1
2930

30-
func newPortForwarder(sshConfig *ssh.SSHConfig, sshHostPort int, rules []limatype.PortForward, ignore bool, vmType limatype.VMType) *portForwarder {
31+
func newPortForwarder(sshConfig *ssh.SSHConfig, sshHostAddr string, sshHostPort int, rules []limatype.PortForward, ignore bool, vmType limatype.VMType) *portForwarder {
3132
return &portForwarder{
3233
sshConfig: sshConfig,
34+
sshHostAddr: sshHostAddr,
3335
sshHostPort: sshHostPort,
3436
rules: rules,
3537
ignore: ignore,
@@ -96,7 +98,7 @@ func (pf *portForwarder) OnEvent(ctx context.Context, ev *api.Event) {
9698
continue
9799
}
98100
logrus.Infof("Stopping forwarding TCP from %s to %s", remote, local)
99-
if err := forwardTCP(ctx, pf.sshConfig, pf.sshHostPort, local, remote, verbCancel); err != nil {
101+
if err := forwardTCP(ctx, pf.sshConfig, pf.sshHostAddr, pf.sshHostPort, local, remote, verbCancel); err != nil {
100102
logrus.WithError(err).Warnf("failed to stop forwarding tcp port %d", f.Port)
101103
}
102104
}
@@ -112,7 +114,7 @@ func (pf *portForwarder) OnEvent(ctx context.Context, ev *api.Event) {
112114
continue
113115
}
114116
logrus.Infof("Forwarding TCP from %s to %s", remote, local)
115-
if err := forwardTCP(ctx, pf.sshConfig, pf.sshHostPort, local, remote, verbForward); err != nil {
117+
if err := forwardTCP(ctx, pf.sshConfig, pf.sshHostAddr, pf.sshHostPort, local, remote, verbForward); err != nil {
116118
logrus.WithError(err).Warnf("failed to set up forwarding tcp port %d (negligible if already forwarded)", f.Port)
117119
}
118120
}

pkg/hostagent/port_darwin.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import (
2020
)
2121

2222
// forwardTCP is not thread-safe.
23-
func forwardTCP(ctx context.Context, sshConfig *ssh.SSHConfig, port int, local, remote, verb string) error {
23+
func forwardTCP(ctx context.Context, sshConfig *ssh.SSHConfig, addr string, port int, local, remote, verb string) error {
2424
if strings.HasPrefix(local, "/") {
25-
return forwardSSH(ctx, sshConfig, port, local, remote, verb, false)
25+
return forwardSSH(ctx, sshConfig, addr, port, local, remote, verb, false)
2626
}
2727
localIPStr, localPortStr, err := net.SplitHostPort(local)
2828
if err != nil {
@@ -35,7 +35,7 @@ func forwardTCP(ctx context.Context, sshConfig *ssh.SSHConfig, port int, local,
3535
}
3636

3737
if !localIP.Equal(IPv4loopback1) || localPort >= 1024 {
38-
return forwardSSH(ctx, sshConfig, port, local, remote, verb, false)
38+
return forwardSSH(ctx, sshConfig, addr, port, local, remote, verb, false)
3939
}
4040

4141
// on macOS, listening on 127.0.0.1:80 requires root while 0.0.0.0:80 does not require root.
@@ -50,7 +50,7 @@ func forwardTCP(ctx context.Context, sshConfig *ssh.SSHConfig, port int, local,
5050
localUnix := plf.unixAddr.Name
5151
_ = plf.Close()
5252
delete(pseudoLoopbackForwarders, local)
53-
if err := forwardSSH(ctx, sshConfig, port, localUnix, remote, verb, false); err != nil {
53+
if err := forwardSSH(ctx, sshConfig, addr, port, localUnix, remote, verb, false); err != nil {
5454
return err
5555
}
5656
} else {
@@ -65,12 +65,12 @@ func forwardTCP(ctx context.Context, sshConfig *ssh.SSHConfig, port int, local,
6565
}
6666
localUnix := filepath.Join(localUnixDir, "sock")
6767
logrus.Debugf("forwarding %q to %q", localUnix, remote)
68-
if err := forwardSSH(ctx, sshConfig, port, localUnix, remote, verb, false); err != nil {
68+
if err := forwardSSH(ctx, sshConfig, addr, port, localUnix, remote, verb, false); err != nil {
6969
return err
7070
}
7171
plf, err := newPseudoLoopbackForwarder(localPort, localUnix)
7272
if err != nil {
73-
if cancelErr := forwardSSH(ctx, sshConfig, port, localUnix, remote, verbCancel, false); cancelErr != nil {
73+
if cancelErr := forwardSSH(ctx, sshConfig, addr, port, localUnix, remote, verbCancel, false); cancelErr != nil {
7474
logrus.WithError(cancelErr).Warnf("failed to cancel forwarding %q to %q", localUnix, remote)
7575
}
7676
return err

0 commit comments

Comments
 (0)