Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #225986

Re: ssh key used for login

From Rainer Dorsch <ml@bokomoko.de>
Newsgroups linux.debian.user
Subject Re: ssh key used for login
Date 2020-08-07 19:20 +0200
Message-ID <ABec9-1Ce-3@gated-at.bofh.it> (permalink)
References <ABcDn-An-1@gated-at.bofh.it> <ABcN3-DL-1@gated-at.bofh.it>
Organization @home

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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/

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

ssh key used for login Rainer Dorsch <ml@bokomoko.de> - 2020-08-07 17:40 +0200
  Re: ssh key used for login john doe <johndoe65534@mail.com> - 2020-08-07 17:50 +0200
    Re: ssh key used for login Rainer Dorsch <ml@bokomoko.de> - 2020-08-07 19:20 +0200
      Re: ssh key used for login <tomas@tuxteam.de> - 2020-08-07 21:10 +0200
  Re: ssh key used for login Kushal Kumaran <kushal@locationd.net> - 2020-08-08 02:30 +0200
    Re: ssh key used for login echo test <echotest09@gmail.com> - 2020-08-08 16:50 +0200
    Re: ssh key used for login Rainer Dorsch <ml@bokomoko.de> - 2020-08-09 22:00 +0200

csiph-web