0

I want to execute a script after outbound ssh.

I have two servers (A) and (B), and a computer (C).

(C) can connect to (A) via SSH but can't connect to (B).

And (A) can connect to (B) via SSH.

But (C) can do multi-hop ssh to go to (B):

C -> A -> B

So I want to log the outbound ssh in (A) with this variable ${SSH_CLIENT%% *} to know if (C) do a multi-hop to connect to (B).

1
  • Which computer needs to know this? Do you want the running shell in B to know that it really originated in C, or something else? Do you have the user's cooperation, or are you trying to catch users who do this? And do you have root access to some of these computers?
    – alexis
    May 13, 2015 at 22:25

2 Answers 2

0

of course it is. because when you logged in using ssh you just run a new process of the service sshd which means you can open unlimited tunnel between C and B by A using ssh service also you can use crontab to make an auto-executed command and that after you logged out or close the connection with B.

2
  • Thank you. i want to log the outbound ssh in (A) and not after logged out from B
    – hamza
    May 13, 2015 at 10:22
  • Sorry i didn't got your point. please tell more about what are you want exactly? Jun 6, 2016 at 17:16
0

Easiest option would to simply rename the /usr/bin/ssh binary on A to ssh.bin and stick a wrapper shell script, called ssh, in the directory, that adds whatever logging you want before calling ssh.bin eg. Shell scripting: Write message to a syslog / log file

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .