comparison dropbearkey.c @ 324:bc7c134982df

Include user@host in the pubkey line, since it's sometimes very useful
author Matt Johnston <matt@ucc.asn.au>
date Wed, 07 Jun 2006 14:48:35 +0000
parents 0cfba3034be5
children 0e4f225b7e07
comparison
equal deleted inserted replaced
323:3bfbe95f9a14 324:bc7c134982df
295 unsigned long base64len; 295 unsigned long base64len;
296 int err; 296 int err;
297 const char * typestring = NULL; 297 const char * typestring = NULL;
298 char *fp = NULL; 298 char *fp = NULL;
299 int len; 299 int len;
300 struct passwd * pw = NULL;
301 char * username = NULL;
302 char hostname[100];
300 303
301 buf = buf_new(MAX_PUBKEY_SIZE); 304 buf = buf_new(MAX_PUBKEY_SIZE);
302 buf_put_pub_key(buf, key, keytype); 305 buf_put_pub_key(buf, key, keytype);
303 buf_setpos(buf, 4); 306 buf_setpos(buf, 4);
304 307
313 316
314 typestring = signkey_name_from_type(keytype, &err); 317 typestring = signkey_name_from_type(keytype, &err);
315 318
316 fp = sign_key_fingerprint(buf_getptr(buf, len), len); 319 fp = sign_key_fingerprint(buf_getptr(buf, len), len);
317 320
318 printf("Public key portion is:\n%s %s\nFingerprint: %s\n", 321 /* a user@host comment is informative */
319 typestring, base64key, fp); 322 username = "";
323 pw = getpwuid(getuid());
324 if (pw)
325 {
326 username = pw->pw_name;
327 }
328
329 gethostname(hostname, sizeof(hostname));
330 hostname[sizeof(hostname)-1] = '\0';
331
332 printf("Public key portion is:\n%s %s %s@%s\nFingerprint: %s\n",
333 typestring, base64key, username, hostname, fp);
320 334
321 m_free(fp); 335 m_free(fp);
322 buf_free(buf); 336 buf_free(buf);
323 } 337 }
324 338