diff options
author | djm@openbsd.org <djm@openbsd.org> | 2015-11-18 08:37:28 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-11-18 19:40:25 +1100 |
commit | bcb7bc77bbb1535d1008c7714085556f3065d99d (patch) | |
tree | 6f4d1e3bbabe09bdbeac6fb193ea79c8488e29fc | |
parent | 259adb6179e23195c8f6913635ea71040d1ccd63 (diff) |
upstream commit
fix "ssh-keygen -l" of private key, broken in support for
multiple plain keys on stdin
Upstream-ID: 6b3132d2c62d03d0bad6f2bcd7e2d8b7dab5cd9d
-rw-r--r-- | ssh-keygen.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c index 5c02d7817..f9091951e 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-keygen.c,v 1.279 2015/11/16 22:53:07 djm Exp $ */ | 1 | /* $OpenBSD: ssh-keygen.c,v 1.280 2015/11/18 08:37:28 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -861,8 +861,15 @@ fingerprint_private(const char *path) | |||
861 | 861 | ||
862 | if (stat(identity_file, &st) < 0) | 862 | if (stat(identity_file, &st) < 0) |
863 | fatal("%s: %s", path, strerror(errno)); | 863 | fatal("%s: %s", path, strerror(errno)); |
864 | if ((r = sshkey_load_public(path, &public, &comment)) != 0) | 864 | if ((r = sshkey_load_public(path, &public, &comment)) != 0) { |
865 | fatal("Error loading public key \"%s\": %s", path, ssh_err(r)); | 865 | debug("load public \"%s\": %s", path, ssh_err(r)); |
866 | if ((r = sshkey_load_private(path, NULL, | ||
867 | &public, &comment)) != 0) { | ||
868 | debug("load private \"%s\": %s", path, ssh_err(r)); | ||
869 | fatal("%s is not a key file.", path); | ||
870 | } | ||
871 | } | ||
872 | |||
866 | fingerprint_one_key(public, comment); | 873 | fingerprint_one_key(public, comment); |
867 | sshkey_free(public); | 874 | sshkey_free(public); |
868 | free(comment); | 875 | free(comment); |
@@ -907,7 +914,7 @@ do_fingerprint(struct passwd *pw) | |||
907 | * not reading from stdin (XXX support private keys on stdin). | 914 | * not reading from stdin (XXX support private keys on stdin). |
908 | */ | 915 | */ |
909 | if (lnum == 1 && strcmp(identity_file, "-") != 0 && | 916 | if (lnum == 1 && strcmp(identity_file, "-") != 0 && |
910 | strstr(cp, "SSH PRIVATE KEY") != NULL) { | 917 | strstr(cp, "PRIVATE KEY") != NULL) { |
911 | fclose(f); | 918 | fclose(f); |
912 | fingerprint_private(path); | 919 | fingerprint_private(path); |
913 | exit(0); | 920 | exit(0); |