Cheng
Cheng

Reputation: 4886

How to get current user's ssh public key from the Linux ssh server?

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 [email protected] Hi Ben! You've successfully authenticated, but GitHub does not provide shell access.

My question is how to get the public key then?

Upvotes: 0

Views: 2020

Answers (1)

user149341
user149341

Reputation:

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.

Upvotes: 2

Related Questions