Lurker News

Comments (245) 68 threads

chrisfosterelli14 replies#
FYI, this happens because SSH automatically presents a public key to the server when trying to authenticate. If the server doesn't know that key, then SSH tries the next one. You can enumerate all of someone's keys this way (like this SSH server does)

If you want to disable this sort of behaviour you can disable SSH from sending keys automatically, and then tell SSH which identity files need to be sent to each host.
In your .ssh/config, something like:

    # Ignore SSH keys unless specified in Host subsection
    IdentitiesOnly yes

    # Send your public key to github only
    Host github.com
        IdentityFile ~/.ssh/id_rsa
This is also handy if you're security conscious and like to use a different private/public key pair for each host you have an account with!
FiloSottile6 replies#
Exactly! Once I get the keys I just check them against a scraped database of GitHub keys and ask the API for your name.

(And if you have agent forwarding active I show you a big WARNING [0].)
There's an explanation in the README [1] but the actually interesting stuff is in server.go [2]. Finally I mentioned a few reasons it might not work for you below [3].
[0] http://git.io/vOVYm
[1] https://github.com/FiloSottile/whosthere
[2] https://github.com/FiloSottile/whosthere/blob/master/src/ssh...
[3] https://news.ycombinator.com/item?id=10005169

songgao1 reply#
This might be more obvious than I thought, but could you explain how you scraped all of GitHub keys throughout the entire user-base?
jvehent1 reply#
It's a cool awareness experiment. Ultimately, public keys are public and people shouldn't be afraid of sharing them.

Agent forwarding sharing is a big one though. Getting people to stop doing that automatically takes a lot of education. https://wiki.mozilla.org/Security/Guidelines/OpenSSH#SSH_age...

marcosdumay1 reply#
The public keys should be ok. But the comment on them may be a problem.

Continue this thread — 1 reply

JoshTriplett5 replies#
> (And if you have agent forwarding active I show you a big WARNING [0].)

It amazes me that people enable that for random servers. Seems like SSH should make that harder. Enabling it for a specific server you trust makes sense; enabling it for all servers doesn't. SSH could reject "ForwardAgent" outside a Host block, for instance, and force you to at least write a "Host *" block.
EDIT: Check out this search: https://github.com/search?utf8=%E2%9C%93&q=ForwardAgent&type...

Continue this thread — 1 reply

phamilton14 replies#
For those who don't get why this is terrible, imagine if GitHub were compromised and their ssh agent tampered with. When you clone a repo, they could use your forwarded agent to log into your production hosts. That's pretty bad.

Continue this thread — 14 replies

scintill763 replies#
I also use the -c (confirm) flag with ssh-add. I don't forward the agent willy-nilly, but if someone still manages to compromise the agent, I will hopefully know when I'm getting confirmation popups I didn't initiate.

Continue this thread — 3 replies

Sevrene#
There's something I found on hacker news awhile back that can allow you to use ForwardAgent while limiting your identities so that you can forward your ssh agent, but it only forwards the identity you used to connect to that server. It starts up a separate agent for each identity when you invoke it.

You can find it at: https://github.com/ccontavalli/ssh-ident

jsmeaton#
Thanks for the tip. I use ForwardAgent for all my servers at work, but I had it defined in a "Host *" block. I've now setup separate blocks for my work domains and have moved ForwardAgent into there alone. Never knew it was a risk until this thread.
brandonbloom1 reply#
And now I've rotated my keys and fixed my ssh config file. Thanks :-)
umangd#
why rotate them? They're just public keys anyways. Useless on their own.
FiloSottile#
Thanks for the link, adding a warning for that, too.
rhino42#
Thanks for the warning by the way! Moved forwardagent to specific servers.

I almost always log into trusted servers, but it's good to be preemptive ;-)

ars1 reply#
Is there a way to set that in bulk so all hosts in your config send identities, but those not specified don't, without putting IdentityFile for every one?
azernik1 reply#
You can create a host block that matches multiple hosts:

    IdentitiesOnly yes

    Host first second third fourth
        IdentitiesOnly no
If you then wanted to have per-host configs you'd have to create more host blocks, but at least this way the added overhead of "IdentitesOnly yes" doesn't grow too fast with the number of hosts involved.
jlgaddis#
Untested but you should also be able to use "Match" directives as well, assuming there's something in common you can match on, e.g.:

  Match Host *.example.com, 192.0.2.*
    IdentitiesOnly no
c22#
This only worked for me after I renamed id_rsa (and id_rsa.pub).
RexRollman#
I never realized that SSH does this. Thank you.
jpmattia#
This really need to be better known.
mirimir#
Thanks!
leepowers1 reply#
I added IdentitiesOnly to my config recently. Partially for security. But also because an non-Github git service would bail whenever too many incorrect identity files were attempted. I've also had SSH servers bail when trying too many keys/identities.

Continue this thread — 1 reply

Continue this thread — 7 more replies

acomjean5 replies#
Didn't work for me. Here's what I got.

I cleaned out .ssh/knownhosts after connecting.

    +---------------------------------------------------------------------+
    |                                                                     |
    |             _o/ Hello!                                              |
    |                                                                     |
    |                                                                     |
    |  Did you know that ssh sends all your public keys to any server     |
    |  it tries to authenticate to? You can see yours echoed below.       |
    |                                                                     |
    |  We tried to use that to find your GitHub username, but we          |
    |  couldn't :( maybe you don't even have GitHub ssh keys, do you?     |
    |                                                                     |
    |  By the way, did you know that GitHub publishes all users'          |
    |  ssh public keys and Ben (benjojo.co.uk) grabbed them all?          |
    |                                                                     |
    |  That's pretty handy at times :) But not this time :(               |
    |                                                                     |
    |                                                                     |
    |  P.S. This whole thingy is Open Source! (And written in Go!)        |
    |  https://github.com/FiloSottile/whosthere                           |
    |                                                                     |
    |  -- @FiloSottile (https://twitter.com/FiloSottile)                  |
    |                                                                     |
    +---------------------------------------------------------------------+

Connection to whoami.filippo.io closed.

Arams-MacBook-Pro:~ acomjean$ emacs .ssh/known_hosts

joeblau1 reply#
Didn't work for me either. It seems like it fails more than it succeeds based on the results posted in this thread.
riffraff2 replies#
presumably, those for which it worked are less likely to post? FWIW, it worked for me.
joeblau1 reply#
That is true! I didn't think about that.

Continue this thread — 1 reply

igravious#
and it worked for me too, just thought i'd chime in here. nice educational and simple project.
bmelton1 reply#
It's probably most apt to working when the local username is the same as the username in your SSH keys.

If your local username is something like "johndoe", while your server logins (and keys mapping to them) is "jdoe", it isn't likely to align the one to the other.
If your local and remote usernames tend to be the same, and they are also the same as your Github keys, then it's probably pretty likely to be accurate.

taejo#
It's based exclusively on the public key. My local username and github login are unrelated, and it worked for me.
FiloSottile5 replies#
Hi! A few reasons it might fail:

* You don't have your SSH keys on GitHub
* You don't have your GitHub keys on that laptop
* Your key is not RSA (because I'm LAZY)
* Your ssh version uses only recent algorithms not supported by Go's x/crypto/ssh
* You actually disabled IdentityKeys
Nothing to do with usernames or heuristics, by the way. All it does is first enumerate your client keys, then let you in, then check a huge GitHub keys database, then ask the GitHub API for your name.
https://github.com/FiloSottile/whosthere#how-it-works

rmetzler1 reply#
- The key might be to new for the dataset.
lelandbatey#
This was the case for me. The keys I'm using now I added this past weekend, and I get the "couldn't find you" message.
noobermin#
Whenever I push, I login. Apparently this laziness saved my ass this time. Of course, this could be used on any service I ssh into regularly and has a scrappable listing of users, so it's good of you to bring this up.
microcolonel#
I'm using ed25519 with Github, figured it was just laziness. (also deliberately set it up to send that key because it wouldn't normally).
hobarrera#
I had the same result, and was rather surprised. It's probably because I have a DSA key.

Aren't these published by github too?

Continue this thread — 1 more reply

Continue this thread — 2 more replies

_wmd2 replies#
Didn't work for me, not because I don't have a Github key, but because I use separate keys for everything, and don't have a default key (requires plenty of ~/.ssh/config muckery).

I had been doing this because I'm paranoid, and because I have a tendency to copy keys for my colo boxes to work computers, and my Git keys to the colo boxes. Now I have a new reason -- public keys basically act like a giant supercookie for SSH.

Continue this thread — 2 replies

scosman2 replies#
"don't worry, I don't have any OpenSSH 0day" > That's exactly what someone with a 0 day would say!

Continue this thread — 2 replies

Load more comments