Skip to content

Commit

Permalink
fix "exit status 255" issue with port forwarding
Browse files Browse the repository at this point in the history
fixes "exit status 255" issue with port forwarding
  • Loading branch information
hamir-suspect committed Jan 10, 2023
2 parents 9af6ccb + 342608f commit 6154c44
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 6154c44

Please sign in to comment.