[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ssh key used for login



Am Freitag, 7. August 2020, 17:47:31 CEST schrieb john doe:

> On 8/7/2020 5:07 PM, Rainer Dorsch wrote:

> > Hi,

> >

> > can anybody tell if there is a way to find out the ssh key (out of the

> > ones

> > listed in authorized keys) was used for login to the current session?

>

> Try to increase the log verbosity to 'debug[1|2|3]'.

>

 

Thanks for the reply, but it seems my question was not precise enough.

 

I want to find it out in a script which runs on the server, e.g.

 

ssh server.domain myscript.sh

 

Is there a way to find out in myscript.sh which ssh key was used for login.

 

There are a number of ssh environment vars, but none of them contains the ssh key (or even better the "user label" after the public key):

 

declare -x SHLVL="1"
declare -x SSH_CLIENT="192.168.7.203 56018 22"
declare -x SSH_CONNECTION="192.168.7.203 56018 192.168.7.1 22"
declare -x SSH_TTY="/dev/pts/2"

Thanks

Rainer

 

--

Rainer Dorsch

http://bokomoko.de/


Reply to: