1

i have a ssh jumphost. On the sshjumphost i wanna execute
always a python script if user want use my jumphost to jump.

client1 -------- jumphost ---------targethost

Client use following command:

ssh -o ProxyCommand="ssh -W %h:%p test\\\\[email protected]" user@targethost

I used the server sshd_config and set

ForceCommand scriptname

But my script dont triggered if a client use the command above.

But if i use following command:

ssh [email protected]  

then my script was triggered.

What can i do to trigger always a script if a user wanna use my jumphost?

Best regards mobios

mobios
  • 11
  • 1
  • `/etc/profile` is probably your best bet. See https://unix.stackexchange.com/questions/56083/how-to-write-a-shell-script-that-gets-executed-on-login – Panki Jul 08 '19 at 11:24
  • possible dupe: https://unix.stackexchange.com/questions/525614/logging-for-proxycommand ? – Alex Stragies Jul 08 '19 at 12:06
  • Thanks for your reply Panki. But if a write a script and put it under /etc/profile.d it would be not trigerred. I tested currenty. I use command ssh -o ProxyCommand="ssh -W %h:%p test\\\\[email protected]" user@targethost. Any Idea ? I need a methode where always a script would be triggered. – mobios Jul 09 '19 at 06:11

1 Answers1

0

If you want to run a script on user level the you may need to put that script/command in the /home//.bashrc for BASH shell, put to the right file according to the users login SHELL.

Ex:

[RHuser@LinuxServer ~]$ cat .bashrc

Source global definitions

if [ -f /etc/bashrc ]; then . /etc/bashrc fi

User specific aliases and functions

uname -a;uptime

[RHuser@LinuxServer ~]$

Output

[RHuser@Jumpboxserver ~]$ ssh LinuxServer RHuser@LinuxServer's password: Authentication successful. 20:22:16 up 4 days, 8:22, 1 user, load average: 0.00, 0.00, 0.00 [RHuser@LinuxServer ~]$