This commit is contained in:
parent
00571d8091
commit
068ef34709
2
runner/hello.txt
Normal file
2
runner/hello.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
lkjdfslka
|
||||||
|
|
@ -7,7 +7,7 @@
|
|||||||
# )
|
# )
|
||||||
|
|
||||||
JSON=$(cat <<'EOF'
|
JSON=$(cat <<'EOF'
|
||||||
{"command":"nano","args":["-w","./hello.txt"],"ssh":{"host":"localhost","user":"j","key":"auto"},"options":{"interactive":true},"env":{"TERM":"xterm-256color"}}
|
{"command":"nano","args":["-w","./hello.txt"],"options":{"interactive":true}}
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -356,6 +356,10 @@ int Runner::execute_ssh(
|
|||||||
ssh_options_set(session, SSH_OPTIONS_PORT, &port);
|
ssh_options_set(session, SSH_OPTIONS_PORT, &port);
|
||||||
ssh_options_set(session, SSH_OPTIONS_USER, user.c_str());
|
ssh_options_set(session, SSH_OPTIONS_USER, user.c_str());
|
||||||
|
|
||||||
|
// Set pseudo-terminal flag (equivalent to ssh -tt)
|
||||||
|
int flag = 1;
|
||||||
|
ssh_options_set(session, SSH_OPTIONS_STRICTHOSTKEYCHECK, &flag);
|
||||||
|
|
||||||
// Connect to server
|
// Connect to server
|
||||||
int rc = ssh_connect(session);
|
int rc = ssh_connect(session);
|
||||||
if (rc != SSH_OK) {
|
if (rc != SSH_OK) {
|
||||||
@ -426,19 +430,28 @@ int Runner::execute_ssh(
|
|||||||
if (interactive) {
|
if (interactive) {
|
||||||
// Request a pseudo-terminal for interactive commands with specific term type
|
// Request a pseudo-terminal for interactive commands with specific term type
|
||||||
const char* term_type = "xterm-256color";
|
const char* term_type = "xterm-256color";
|
||||||
rc = ssh_channel_request_pty_size(channel, term_type, 80, 24);
|
|
||||||
if (rc != SSH_OK) {
|
// Force PTY allocation first with basic settings
|
||||||
// Fallback to basic PTY request
|
|
||||||
std::cerr << "Warning: Could not set PTY with size, falling back to basic PTY" << std::endl;
|
|
||||||
rc = ssh_channel_request_pty(channel);
|
rc = ssh_channel_request_pty(channel);
|
||||||
if (rc != SSH_OK) {
|
if (rc != SSH_OK) {
|
||||||
std::cerr << "Error requesting PTY: " << ssh_get_error(session) << std::endl;
|
std::cerr << "Error requesting basic PTY: " << ssh_get_error(session) << std::endl;
|
||||||
ssh_channel_close(channel);
|
ssh_channel_close(channel);
|
||||||
ssh_channel_free(channel);
|
ssh_channel_free(channel);
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
ssh_free(session);
|
ssh_free(session);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Then set the size and term type
|
||||||
|
rc = ssh_channel_request_pty_size(channel, term_type, 80, 24);
|
||||||
|
if (rc != SSH_OK) {
|
||||||
|
std::cerr << "Warning: Could not set PTY size, but continuing anyway" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up terminal mode to be more raw (important for full-screen apps)
|
||||||
|
if (env.find("TERM") == env.end()) {
|
||||||
|
// Add TERM environment if not present
|
||||||
|
cmd_stream << "export TERM=\"" << term_type << "\"; ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user