# HG changeset patch # User Matt Johnston # Date 1149691715 0 # Node ID bc7c134982dfafee5f241b5048319969cc2e9544 # Parent 3bfbe95f9a144103f2833764a95388e48b4779f0 Include user@host in the pubkey line, since it's sometimes very useful diff -r 3bfbe95f9a14 -r bc7c134982df dropbearkey.c --- a/dropbearkey.c Wed Jun 07 14:10:21 2006 +0000 +++ b/dropbearkey.c Wed Jun 07 14:48:35 2006 +0000 @@ -297,6 +297,9 @@ 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 @@ 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);