-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSH: Support executing commands and interactive shell with port forwarding #48
SSH: Support executing commands and interactive shell with port forwarding #48
Conversation
ENG-1653 p0 cli SSH: Support executing commands with port forwarding
The Possible Complications
Definition of Done
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you double-check the functionality of:
- Typing
exit
in the SSH session - Typing
CTRL-d
in the SSH session - Resizing the SSH window (especially in a vi or nano window)
...process.env, | ||
...credentials, | ||
}, | ||
stdio: ["inherit", "pipe", "pipe"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this need to be ["inherit", "inherit", "pipe"]
in order for the pty to be preserved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be different for the ssh session and the port-forward subprocesses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't mind getting multiple "starting session" messages, then we can switch to ["inherit", "inherit", "pipe"]
. What do you think?
}); | ||
|
||
// Ensures that content from the child process is printed to the terminal and the proxy stream | ||
childProcess.stdout.pipe(proxyStream).pipe(process.stdout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is dropping stderr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should be dropping stderr. From my understanding i'm piping the original output into a proxy stream so I can process the messages and then passing it back to process.stdout, which should leave stderr unaffected.
Closing this PR, an alternative approach is being taken in #50 which does not used detached processes and also doesn't intercept the primary process' output stream |
This PR enables
p0 ssh <instance> -L 56789:80
p0 ssh <instance> sleep 10 -L 56789:80
In order to support this behavior execution of the port forwarding command is done in a child process. The child process uses streams to intercept and merge the child processes (and it's descendent's) output into the parent processes stdout.