mirror of
https://github.com/clearml/dropbear
synced 2025-02-07 13:21:15 +00:00
Add '-y' option to dbclient to accept the host key without checking
- patch from Luciano Miguel Ferreira Rocha. --HG-- extra : convert_revision : 924b731b50d4147eed8e9382c98a2573259a6cad
This commit is contained in:
parent
fc0e723805
commit
cd0a08896c
45
cli-kex.c
45
cli-kex.c
@ -119,6 +119,13 @@ static void ask_to_confirm(unsigned char* keyblob, unsigned int keybloblen) {
|
|||||||
char response = 'z';
|
char response = 'z';
|
||||||
|
|
||||||
fp = sign_key_fingerprint(keyblob, keybloblen);
|
fp = sign_key_fingerprint(keyblob, keybloblen);
|
||||||
|
if (cli_opts.always_accept_key) {
|
||||||
|
fprintf(stderr, "\nHost '%s' key accepted unconditionally.\n(fingerprint %s)\n",
|
||||||
|
cli_opts.remotehost,
|
||||||
|
fp);
|
||||||
|
m_free(fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
fprintf(stderr, "\nHost '%s' is not in the trusted hosts file.\n(fingerprint %s)\nDo you want to continue connecting? (y/n)\n",
|
fprintf(stderr, "\nHost '%s' is not in the trusted hosts file.\n(fingerprint %s)\nDo you want to continue connecting? (y/n)\n",
|
||||||
cli_opts.remotehost,
|
cli_opts.remotehost,
|
||||||
fp);
|
fp);
|
||||||
@ -268,24 +275,26 @@ static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen) {
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* put the new entry in the file */
|
if (!cli_opts.always_accept_key) {
|
||||||
fseek(hostsfile, 0, SEEK_END); /* In case it wasn't opened append */
|
/* put the new entry in the file */
|
||||||
buf_setpos(line, 0);
|
fseek(hostsfile, 0, SEEK_END); /* In case it wasn't opened append */
|
||||||
buf_setlen(line, 0);
|
buf_setpos(line, 0);
|
||||||
buf_putbytes(line, ses.remotehost, hostlen);
|
buf_setlen(line, 0);
|
||||||
buf_putbyte(line, ' ');
|
buf_putbytes(line, ses.remotehost, hostlen);
|
||||||
buf_putbytes(line, algoname, algolen);
|
buf_putbyte(line, ' ');
|
||||||
buf_putbyte(line, ' ');
|
buf_putbytes(line, algoname, algolen);
|
||||||
len = line->size - line->pos;
|
buf_putbyte(line, ' ');
|
||||||
TRACE(("keybloblen %d, len %d", keybloblen, len))
|
len = line->size - line->pos;
|
||||||
/* The only failure with base64 is buffer_overflow, but buf_getwriteptr
|
TRACE(("keybloblen %d, len %d", keybloblen, len))
|
||||||
* will die horribly in the case anyway */
|
/* The only failure with base64 is buffer_overflow, but buf_getwriteptr
|
||||||
base64_encode(keyblob, keybloblen, buf_getwriteptr(line, len), &len);
|
* will die horribly in the case anyway */
|
||||||
buf_incrwritepos(line, len);
|
base64_encode(keyblob, keybloblen, buf_getwriteptr(line, len), &len);
|
||||||
buf_putbyte(line, '\n');
|
buf_incrwritepos(line, len);
|
||||||
buf_setpos(line, 0);
|
buf_putbyte(line, '\n');
|
||||||
fwrite(buf_getptr(line, line->len), line->len, 1, hostsfile);
|
buf_setpos(line, 0);
|
||||||
/* We ignore errors, since there's not much we can do about them */
|
fwrite(buf_getptr(line, line->len), line->len, 1, hostsfile);
|
||||||
|
/* We ignore errors, since there's not much we can do about them */
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (hostsfile != NULL) {
|
if (hostsfile != NULL) {
|
||||||
|
@ -52,6 +52,7 @@ static void printhelp() {
|
|||||||
"-T Don't allocate a pty\n"
|
"-T Don't allocate a pty\n"
|
||||||
"-N Don't run a remote command\n"
|
"-N Don't run a remote command\n"
|
||||||
"-f Run in background after auth\n"
|
"-f Run in background after auth\n"
|
||||||
|
"-y Always accept remote host key if unknown\n"
|
||||||
#ifdef ENABLE_CLI_PUBKEY_AUTH
|
#ifdef ENABLE_CLI_PUBKEY_AUTH
|
||||||
"-i <identityfile> (multiple allowed)\n"
|
"-i <identityfile> (multiple allowed)\n"
|
||||||
#endif
|
#endif
|
||||||
@ -93,6 +94,7 @@ void cli_getopts(int argc, char ** argv) {
|
|||||||
cli_opts.no_cmd = 0;
|
cli_opts.no_cmd = 0;
|
||||||
cli_opts.backgrounded = 0;
|
cli_opts.backgrounded = 0;
|
||||||
cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */
|
cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */
|
||||||
|
cli_opts.always_accept_key = 0;
|
||||||
#ifdef ENABLE_CLI_PUBKEY_AUTH
|
#ifdef ENABLE_CLI_PUBKEY_AUTH
|
||||||
cli_opts.privkeys = NULL;
|
cli_opts.privkeys = NULL;
|
||||||
#endif
|
#endif
|
||||||
@ -148,6 +150,9 @@ void cli_getopts(int argc, char ** argv) {
|
|||||||
/* A flag *waves* */
|
/* A flag *waves* */
|
||||||
|
|
||||||
switch (argv[i][1]) {
|
switch (argv[i][1]) {
|
||||||
|
case 'y': /* always accept the remote hostkey */
|
||||||
|
cli_opts.always_accept_key = 1;
|
||||||
|
break;
|
||||||
case 'p': /* remoteport */
|
case 'p': /* remoteport */
|
||||||
next = &cli_opts.remoteport;
|
next = &cli_opts.remoteport;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user