summaryrefslogtreecommitdiff
path: root/dropbearkey.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2006-06-07 14:48:35 +0000
committerMatt Johnston <matt@ucc.asn.au>2006-06-07 14:48:35 +0000
commitcdec63e0888cc4841cc8fcb27e6e4fc4cd836860 (patch)
treefb4f9cb411280685dd7da3bd12e20bcfb0b5952f /dropbearkey.c
parent4f3c5eb00cdf74680b2029d5e80938fd57941380 (diff)
downloaddropbear-cdec63e0888cc4841cc8fcb27e6e4fc4cd836860.tar.gz
Include user@host in the pubkey line, since it's sometimes very useful
Diffstat (limited to 'dropbearkey.c')
-rw-r--r--dropbearkey.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/dropbearkey.c b/dropbearkey.c
index 8ceefdc..0825053 100644
--- a/dropbearkey.c
+++ b/dropbearkey.c
@@ -297,6 +297,9 @@ static void printpubkey(sign_key * key, int keytype) {
const char * typestring = NULL;
char *fp = NULL;
int len;
+ struct passwd * pw = NULL;
+ char * username = NULL;
+ char hostname[100];
buf = buf_new(MAX_PUBKEY_SIZE);
buf_put_pub_key(buf, key, keytype);
@@ -315,8 +318,19 @@ static void printpubkey(sign_key * key, int keytype) {
fp = sign_key_fingerprint(buf_getptr(buf, len), len);
- printf("Public key portion is:\n%s %s\nFingerprint: %s\n",
- typestring, base64key, fp);
+ /* a user@host comment is informative */
+ username = "";
+ pw = getpwuid(getuid());
+ if (pw)
+ {
+ username = pw->pw_name;
+ }
+
+ gethostname(hostname, sizeof(hostname));
+ hostname[sizeof(hostname)-1] = '\0';
+
+ printf("Public key portion is:\n%s %s %s@%s\nFingerprint: %s\n",
+ typestring, base64key, username, hostname, fp);
m_free(fp);
buf_free(buf);