0

Is there a way for a program at the server to get the public key that the user used for ssh login?

For example, github knows that it's user "Ben" by searching the public key from their database.

ssh -T git@github.com Hi Ben! You've successfully authenticated, but GitHub does not provide shell access.

My question is how to get the public key then?

Cheng
  • 4,816
  • 4
  • 41
  • 44
  • When you connect to the SSH Server, the username is always sent. Thus there's no need to search by public key. – Eugene Mayevski 'Callback Apr 26 '14 at 05:46
  • This question appears to belong on another site in the Stack Exchange network because its not about programming. Perhaps [Super User](https://www.superuser.com/) or [Server Fault](http://serverfault.com/). – jww May 13 '14 at 05:59

1 Answers1

2

Only the SSH server (sshd) can retrieve that information. It is not exposed to processes launched from the server, such as the shell.

The fact that Github is doing this, as well as some circumstantial evidence on their blog, strongly suggests that Github is running a custom SSH server (i.e, not OpenSSH). You would need to write your own SSH server to replicate this functionality.