Closed scott-xu closed 2 days ago
To support creating shell without PTY, we can add a new constructor for Shell
and ShellStream
which does not send PseudoTerminalRequest
.
Here's the same setting in Putty:
SSHJ does have a dedicate allocatePTY method.
void allocatePTY(String term, int cols, int rows, int width, int height, Map<PTYMode, Integer> modes)
throws ConnectionException, TransportException;
try {
ssh.addHostKeyVerifier(new PromiscuousVerifier());
// Set interval to enable keep-alive before connecting
ssh.getConnection().getKeepAlive().setKeepAliveInterval(5);
ssh.connect(args[0]);
ssh.authPassword(args[1], args[2]);
Session session = ssh.startSession();
session.allocateDefaultPTY();
new CountDownLatch(1).await();
try {
session.allocateDefaultPTY();
} finally {
session.close();
}
} finally {
ssh.disconnect();
}
OpenSSH client supports
-T
option to disable pseudo-terminal allocation. Can we add this feature to SSH.NET as well? With this option, the output from remote does not contain control sequences. It is not user-friendly but program-friendly. Program at client side does not need to parse/draw the screen with control sequences to get the correct output.There's already
SshCommand
feature which is similar with this. ButSshCommand
does not support interactions.SshCommand
runs and ends.https://www.man7.org/linux/man-pages/man1/ssh.1.html
-T Disable pseudo-terminal allocation.