OpenSSH 6.4, "ssh-add -l", output to non-tty

Phil Pennock phil.pennock at globnix.org
Thu Apr 17 17:15:57 EST 2014


This one has me perplexed.  OpenSSH6.4p1 on a FreeBSD 7 box (I know it's
old; it's being replaced this month).  I can't spot anything changed in
OpenSSH commit logs or git blame of the current file.

I ssh into the box from a system with OpenSSH6.6p1 and three keys
loaded, RSA, ECDSA and ED25519.

As expected, key_from_blob and key_fingerprint complain about the
ED25519 key in the agent, because they can't handle it.  Not a problem.

However, in this scenario, "ssh-add -l" will only produce output to
stdout if stdout is a tty.

"ssh-add -L" reliably produces output to stdout.

"ssh-add -l" reliably produces output to stdout _unless_ it can't parse
one of the blobs from the agent.

ktrace outputs of the working and non-working scenarios below.  As you
can see, in the broken scenario there's no I/O to stdout.

Can anyone explain what's going on, please?

-Phil


% ktrace ssh-add -l 2>/dev/null
3072 8b:c1:ae:d1:48:5d:a1:c6:1b:3d:50:e1:6b:cd:65:32 /home/pdp/.ssh/id_rsa (RSA)
521 ee:2e:72:bc:53:6d:c2:57:42:2a:3d:e3:67:85:27:a6 /home/pdp/.ssh/id_ecdsa (ECDSA)
% kdump |less
----------------------------8< cut here >8------------------------------
 63697 ssh-add  CALL  socket(PF_LOCAL,SOCK_STREAM,0)
 63697 ssh-add  RET   socket 3
 63697 ssh-add  CALL  fcntl(0x3,F_SETFD,FD_CLOEXEC)
 63697 ssh-add  RET   fcntl 0
 63697 ssh-add  CALL  connect(0x3,0x7fffffffdd80,0x6a)
 63697 ssh-add  NAMI  "/tmp/ssh-fEfqnn0cp4/agent.63353"
 63697 ssh-add  RET   connect 0
 63697 ssh-add  CALL  write(0x3,0x7fffffffd930,0x4)
[... ssh-agent communications, reads back keys, etc ]
 63697 ssh-add  CALL  read(0x3,0x7fffffffd930,0x2d8)
 63697 ssh-add  GIO   fd 3 read 728 bytes
[...]
 63697 ssh-add  RET   read 728/0x2d8
 63697 ssh-add  CALL  fstat(0x1,0x7fffffffd420)
 63697 ssh-add  RET   fstat 0
 63697 ssh-add  CALL  ioctl(0x1,TIOCGETA,0x7fffffffd480)
 63697 ssh-add  RET   ioctl 0
 63697 ssh-add  CALL  write(0x1,0x80202c000,0x51)
 63697 ssh-add  GIO   fd 1 wrote 81 bytes
       "3072 8b:c1:ae:d1:48:5d:a1:c6:1b:3d:50:e1:6b:cd:65:32 /home/pdp/.ssh/id_rsa (RSA)
       "
 63697 ssh-add  RET   write 81/0x51
 63697 ssh-add  CALL  write(0x1,0x80202c000,0x54)
 63697 ssh-add  GIO   fd 1 wrote 84 bytes
       "521 ee:2e:72:bc:53:6d:c2:57:42:2a:3d:e3:67:85:27:a6 /home/pdp/.ssh/id_ecdsa (ECDSA)
       "
 63697 ssh-add  RET   write 84/0x54
 63697 ssh-add  CALL  write(0x2,0x7fffffffd7f0,0x2f)
 63697 ssh-add  GIO   fd 2 wrote 47 bytes
       "key_from_blob: remaining bytes in key blob 36\r
       "
 63697 ssh-add  RET   write 47/0x2f
 63697 ssh-add  CALL  write(0x2,0x7fffffffd880,0x32)
 63697 ssh-add  GIO   fd 2 wrote 50 bytes
       "key_fingerprint: null from key_fingerprint_raw()\r
       "
 63697 ssh-add  RET   write 50/0x32
 63697 ssh-add  CALL  exit(0xff)
----------------------------8< cut here >8------------------------------

% ktrace ssh-add -l 2>/dev/null | cat
----------------------------8< cut here >8------------------------------
 64004 ssh-add  CALL  socket(PF_LOCAL,SOCK_STREAM,0)
 64004 ssh-add  RET   socket 3
 64004 ssh-add  CALL  fcntl(0x3,F_SETFD,FD_CLOEXEC)
 64004 ssh-add  RET   fcntl 0
 64004 ssh-add  CALL  connect(0x3,0x7fffffffdd90,0x6a)
 64004 ssh-add  NAMI  "/tmp/ssh-74wsYwRh3v/agent.62945"
 64004 ssh-add  RET   connect 0
 64004 ssh-add  CALL  write(0x3,0x7fffffffd940,0x4)
[... ssh-agent communications, reads back keys, etc ]
 64004 ssh-add  CALL  read(0x3,0x7fffffffd940,0x2d8)
 64004 ssh-add  GIO   fd 3 read 728 bytes
[...]
 64004 ssh-add  RET   read 728/0x2d8
 64004 ssh-add  CALL  fstat(0x1,0x7fffffffd430)
 64004 ssh-add  RET   fstat 0
 64004 ssh-add  CALL  write(0x2,0x7fffffffd800,0x2f)
 64004 ssh-add  GIO   fd 2 wrote 47 bytes
       "key_from_blob: remaining bytes in key blob 36\r
       "
 64004 ssh-add  RET   write 47/0x2f
 64004 ssh-add  CALL  write(0x2,0x7fffffffd890,0x32)
 64004 ssh-add  GIO   fd 2 wrote 50 bytes
       "key_fingerprint: null from key_fingerprint_raw()\r
       "
 64004 ssh-add  RET   write 50/0x32
 64004 ssh-add  CALL  exit(0xff)
----------------------------8< cut here >8------------------------------


More information about the openssh-unix-dev mailing list