version 1.411, 2020/05/18 04:29:35 |
version 1.413, 2020/06/26 05:02:03 |
|
|
{ |
{ |
struct sshkey **keys; |
struct sshkey **keys; |
size_t nkeys, i; |
size_t nkeys, i; |
int r, ok = -1; |
int r, ret = -1; |
char *fp, *pin = NULL, *pass = NULL, *path, *pubpath; |
char *fp, *pin = NULL, *pass = NULL, *path, *pubpath; |
const char *ext; |
const char *ext; |
|
|
|
|
} |
} |
|
|
if (i >= nkeys) |
if (i >= nkeys) |
ok = 0; /* success */ |
ret = 0; /* success */ |
if (pass != NULL) |
if (pass != NULL) |
freezero(pass, strlen(pass)); |
freezero(pass, strlen(pass)); |
for (i = 0; i < nkeys; i++) |
for (i = 0; i < nkeys; i++) |
sshkey_free(keys[i]); |
sshkey_free(keys[i]); |
free(keys); |
free(keys); |
return ok ? 0 : -1; |
return ret; |
} |
} |
|
|
static void |
static void |
|
|
int |
int |
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
char dotsshdir[PATH_MAX], comment[1024], *passphrase; |
char comment[1024], *passphrase; |
char *rr_hostname = NULL, *ep, *fp, *ra; |
char *rr_hostname = NULL, *ep, *fp, *ra; |
struct sshkey *private, *public; |
struct sshkey *private, *public; |
struct passwd *pw; |
struct passwd *pw; |
struct stat st; |
|
int r, opt, type; |
int r, opt, type; |
int change_passphrase = 0, change_comment = 0, show_cert = 0; |
int change_passphrase = 0, change_comment = 0, show_cert = 0; |
int find_host = 0, delete_host = 0, hash_hosts = 0; |
int find_host = 0, delete_host = 0, hash_hosts = 0; |
|
|
ask_filename(pw, "Enter file in which to save the key"); |
ask_filename(pw, "Enter file in which to save the key"); |
|
|
/* Create ~/.ssh directory if it doesn't already exist. */ |
/* Create ~/.ssh directory if it doesn't already exist. */ |
snprintf(dotsshdir, sizeof dotsshdir, "%s/%s", |
hostfile_create_user_ssh_dir(identity_file, !quiet); |
pw->pw_dir, _PATH_SSH_USER_DIR); |
|
if (strstr(identity_file, dotsshdir) != NULL) { |
|
if (stat(dotsshdir, &st) == -1) { |
|
if (errno != ENOENT) { |
|
error("Could not stat %s: %s", dotsshdir, |
|
strerror(errno)); |
|
} else if (mkdir(dotsshdir, 0700) == -1) { |
|
error("Could not create directory '%s': %s", |
|
dotsshdir, strerror(errno)); |
|
} else if (!quiet) |
|
printf("Created directory '%s'.\n", dotsshdir); |
|
} |
|
} |
|
/* If the file already exists, ask the user to confirm. */ |
/* If the file already exists, ask the user to confirm. */ |
if (!confirm_overwrite(identity_file)) |
if (!confirm_overwrite(identity_file)) |
exit(1); |
exit(1); |