Add SSH options -o UserKnownHostsFile=/dev/null and -o LogLevel ERROR to all...

Add SSH options -o UserKnownHostsFile=/dev/null and -o LogLevel ERROR to all wsssh and wsscp implementations
parent 5345a7b7
......@@ -267,7 +267,7 @@ def main():
i += 1
# Add StrictHostKeyChecking=no and port argument for local tunnel at the beginning
final_args = ['-o', 'StrictHostKeyChecking=no', '-P', str(local_port)] + final_args
final_args = ['-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'LogLevel ERROR', '-P', str(local_port)] + final_args
if debug: print(f"[DEBUG] Final SCP args: {final_args}")
......
......@@ -262,7 +262,7 @@ def main():
final_args.append(arg)
# Add StrictHostKeyChecking=no and port argument for local tunnel
final_args.extend(['-o', 'StrictHostKeyChecking=no', '-p', str(local_port)])
final_args.extend(['-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'LogLevel ERROR', '-p', str(local_port)])
if debug: print(f"[DEBUG] Final SSH args: {final_args}")
......
......@@ -207,8 +207,8 @@ int parse_scp_args(int argc, char *argv[], char **destination, int *scp_port, in
}
char **modify_scp_args(int argc, char *argv[], const char *original_host, int local_port, int *new_argc) {
// Allocate space for: scp + -o + StrictHostKeyChecking=no + -P + port + original args + NULL
char **new_args = malloc((argc + 6) * sizeof(char *));
// Allocate space for: scp + -o + StrictHostKeyChecking=no + -o + UserKnownHostsFile=/dev/null + -o + LogLevel ERROR + -P + port + original args + NULL
char **new_args = malloc((argc + 10) * sizeof(char *));
if (!new_args) {
return NULL;
}
......@@ -220,6 +220,14 @@ char **modify_scp_args(int argc, char *argv[], const char *original_host, int lo
new_args[idx++] = "-o";
new_args[idx++] = "StrictHostKeyChecking=no";
// Add UserKnownHostsFile=/dev/null option
new_args[idx++] = "-o";
new_args[idx++] = "UserKnownHostsFile=/dev/null";
// Add LogLevel ERROR option
new_args[idx++] = "-o";
new_args[idx++] = "LogLevel ERROR";
// Add port argument
new_args[idx++] = "-P";
char *port_str = malloc(16);
......
......@@ -238,8 +238,8 @@ int parse_ssh_args(int argc, char *argv[], char **host, int *ssh_port, int debug
}
char **modify_ssh_args(int argc, char *argv[], const char *original_host, int local_port, int *new_argc) {
// Allocate space for: ssh + -o + StrictHostKeyChecking=no + -p + port + original args + NULL
char **new_args = malloc((argc + 6) * sizeof(char *));
// Allocate space for: ssh + -o + StrictHostKeyChecking=no + -o + UserKnownHostsFile=/dev/null + -o + LogLevel ERROR + -p + port + original args + NULL
char **new_args = malloc((argc + 10) * sizeof(char *));
if (!new_args) {
return NULL;
}
......@@ -251,6 +251,14 @@ char **modify_ssh_args(int argc, char *argv[], const char *original_host, int lo
new_args[idx++] = "-o";
new_args[idx++] = "StrictHostKeyChecking=no";
// Add UserKnownHostsFile=/dev/null option
new_args[idx++] = "-o";
new_args[idx++] = "UserKnownHostsFile=/dev/null";
// Add LogLevel ERROR option
new_args[idx++] = "-o";
new_args[idx++] = "LogLevel ERROR";
// Add port argument for local tunnel
new_args[idx++] = "-p";
char *port_str = malloc(16);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment