summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRyo Nakamura <upa@haeena.net>2022-11-05 22:46:02 +0900
committerRyo Nakamura <upa@haeena.net>2022-11-05 22:46:02 +0900
commit243bf1fa5710c0928e4a52ad4c5a0f0e73022554 (patch)
tree41f692ce8c03534e149841de6600dc84ec50e7ee /src
parent8cb5c81fcfc5a43224c1d2c0eed374d85667a0d8 (diff)
add -H option to disable host key check
tests use this option.
Diffstat (limited to 'src')
-rw-r--r--src/main.c8
-rw-r--r--src/ssh.c2
-rw-r--r--src/ssh.h18
3 files changed, 17 insertions, 11 deletions
diff --git a/src/main.c b/src/main.c
index 4524fd3..ed0b644 100644
--- a/src/main.c
+++ b/src/main.c
@@ -82,7 +82,7 @@ int list_count(struct list_head *head)
void usage(bool print_help) {
printf("mscp v" VERSION ": copy files over multiple ssh connections\n"
"\n"
- "Usage: mscp [CvqDdh] [-n nr_conns]\n"
+ "Usage: mscp [vqDCHdh] [-n nr_conns]\n"
" [-s min_chunk_sz] [-S max_chunk_sz]\n"
" [-b sftp_buf_sz] [-B io_buf_sz]\n"
" [-l login_name] [-p port] [-i identity_file]\n"
@@ -108,6 +108,7 @@ void usage(bool print_help) {
" -i IDENTITY identity file for publickey authentication\n"
" -c CIPHER cipher spec, see `ssh -Q cipher`\n"
" -C enable compression on libssh\n"
+ " -H disable hostkey check\n"
" -d increment ssh debug output level\n"
" -h print this help\n"
"\n");
@@ -178,7 +179,7 @@ int main(int argc, char **argv)
nr_threads = (int)(nr_cpus() / 2);
nr_threads = nr_threads == 0 ? 1 : nr_threads;
- while ((ch = getopt(argc, argv, "n:s:S:b:B:vqDl:p:i:c:Cdh")) != -1) {
+ while ((ch = getopt(argc, argv, "n:s:S:b:B:vqDl:p:i:c:CHdh")) != -1) {
switch (ch) {
case 'n':
nr_threads = atoi(optarg);
@@ -255,6 +256,9 @@ int main(int argc, char **argv)
case 'C':
opts.compress++;
break;
+ case 'H':
+ opts.no_hostkey_check = true;
+ break;
case 'd':
opts.debuglevel++;
break;
diff --git a/src/ssh.c b/src/ssh.c
index c5c53be..9ba7316 100644
--- a/src/ssh.c
+++ b/src/ssh.c
@@ -106,7 +106,7 @@ static ssh_session ssh_make_ssh_session(char *sshdst, struct ssh_opts *opts)
goto disconnect_out;
}
- if (ssh_verify_known_hosts(ssh) != 0) {
+ if (!opts->no_hostkey_check && ssh_verify_known_hosts(ssh) != 0) {
goto disconnect_out;
}
diff --git a/src/ssh.h b/src/ssh.h
index 2dd99f5..413fb6a 100644
--- a/src/ssh.h
+++ b/src/ssh.h
@@ -1,19 +1,21 @@
#ifndef _SSH_H_
#define _SSH_H_
+#include <stdbool.h>
#include <libssh/libssh.h>
#include <libssh/sftp.h>
struct ssh_opts {
- char *login_name; /* -l */
- char *port; /* -p */
- char *identity; /* -i */
- char *cipher; /* -c */
- int compress; /* -C */
- int debuglevel; /* -v */
-
- char *password; /* filled at the first connecting phase */
+ char *login_name; /* -l */
+ char *port; /* -p */
+ char *identity; /* -i */
+ char *cipher; /* -c */
+ int compress; /* -C */
+ int debuglevel; /* -v */
+ bool no_hostkey_check; /* -H */
+
+ char *password; /* filled at the first connecting phase */
};
/* ssh_make_sftp_session() creates sftp_session. sshdst accpets