Skip to content

Commit

Permalink
fixes exit status 255 issue with port forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
hamir-suspect committed Nov 10, 2022
1 parent f4c2c6e commit 342608f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/port_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ func sshAndPortForward(ip string, sshPort int32, username string, localPort stri
userAndIP := fmt.Sprintf("%s@%s", username, ip)
portForwardRule := fmt.Sprintf("%s:0.0.0.0:%s", localPort, remotePort)
noStrictRule := "-oStrictHostKeyChecking=no"
identityOnlyrule := "-oIdentitiesOnly=yes"

sshKeyFile, _ := ioutil.TempFile("", "sem-cli-debug-private-key")
defer os.Remove(sshKeyFile.Name())
sshKeyFile.Write([]byte(sshKey))
sshKeyFile.Close()

fmt.Printf("Forwarding %s:%s -> %s:%s...\n", ip, remotePort, "0.0.0.0", localPort)
sshCmd := exec.Command(sshPath, "-L", portForwardRule, portFlag, noStrictRule, userAndIP, "-i", sshKeyFile.Name(), "sleep infinity")
sshCmd := exec.Command(sshPath, "-L", portForwardRule, portFlag, noStrictRule, identityOnlyrule, userAndIP, "-i", sshKeyFile.Name(), "sleep infinity")

sshCmd.Stdin = os.Stdin
sshCmd.Stdout = os.Stdout
Expand Down

0 comments on commit 342608f

Please sign in to comment.