We help IT Professionals succeed at work.

How can we show the TOKEN value while sshing to a remote server?

Balbir Singh
Balbir Singh asked
on
How can we show the TOKEN value while sshing to a remote server?

from the man page of sshd_config I see belows:
TOKENS
     Arguments to some keywords can make use of tokens, which are expanded at runtime:

           %%    A literal `%'.
           %D    The routing domain in which the incoming connection was received.
           %F    The fingerprint of the CA key.
           %f    The fingerprint of the key or certificate.
           %h    The home directory of the user.
           %i    The key ID in the certificate.
           %K    The base64-encoded CA key.
           %k    The base64-encoded key or certificate for authentication.
           %s    The serial number of the certificate.
           %T    The type of the CA key.
           %t    The key or certificate type.
           %U    The numeric user ID of the target user.
           %u    The username.

Open in new window


and from the man page of ssh_config I find belows:

TOKENS
     Arguments to some keywords can make use of tokens, which are expanded at runtime:

           %%    A literal `%'.
           %C    Hash of %l%h%p%r.
           %d    Local user's home directory.
           %h    The remote hostname.
           %i    The local user ID.
           %L    The local hostname.
           %l    The local hostname, including the domain name.
           %n    The original remote hostname, as given on the command line.
           %p    The remote port.
           %r    The remote username.
           %T    The local tun(4) or tap(4) network interface assigned if tunnel forwarding was requested, or "NONE" otherwise.
           %u    The local username.

Open in new window


Basically I want them to expand to some echo command so that I can see what is the current value when I ssh to a box, both from the client side and server side. I would really appreciate if someone can direct on how to achive it.

Best Regards!
Comment
Watch Question

you can't

Arguments to some keywords can make use of tokens, which are expanded at runtime:

this does not mean you have access to said tokens in your ssh session. you can just use them in some places in the config files

but note that most of that information is available in the environment or by running trivial commands

i do not think said tokens work in the banner but that may be worth a shot
David FavorFractional CTO
Distinguished Expert 2019

Commented:
As skullnobrains mentioned, just because you have config access to a value, doesn't mean the value is passed as a shell environment variable.

Maybe describe what exactly you're trying to see + someone can assist.