SSH through ProxyJump w/ conditional RunCommand

Trying to do a couple things. I have 2 jump hosts I can use to get into my cluster login node. From my laptop to the jump hosts is password. From jump hosts to login node can be key-based, so if I do it all from CLI:


<span style="color:#323232;">[me@home ~]$ ssh user@jump1
</span><span style="color:#323232;">Password:
</span><span style="color:#323232;">[user@jump1 ~]$ ssh user@login1
</span><span style="color:#323232;">[user@login1 ~]$ 
</span>

Same process if I use jump2.

So first thing I’m trying to do is set up my ~/.ssh/config to use the ProxyJump host and key file to get to login1. I have the following:


<span style="color:#323232;">Host jump1
</span><span style="color:#323232;">  Hostname jump1.domain
</span><span style="color:#323232;">Host jump2
</span><span style="color:#323232;">  Hostname jump2.domain
</span><span style="color:#323232;">Host login1
</span><span style="color:#323232;">  Hostname login1.cluster
</span><span style="color:#323232;">  ProxyJump jump1
</span><span style="color:#323232;">  #ProxyJump jump2
</span>

I’m not sure how to configure the IdentityFile entries for each jump host. The user on the jump hosts has different id_rsa keys in ~/.ssh, but both are in the authorized_keys file on login1.

Second thing I’m trying to do is join or start a tmux session. From CLI, I can run:


<span style="color:#323232;">tmux has-session -t mysession || tmux new -s mysession &amp;&amp; tmux a -t mysession
</span>

I’ve learned that to just join a running session (tmux a -t mysession), I need to include “RequestTTY yes” in my ssh config entry for login1. What I can’t get working is the conditional statement that will fire up a new tmux session if it doesn’t already exist.

notabot,

To join or create a session in tmux try: tmux new -As mysession. The -A makes new attach to a session if it already exists.

Using a proxyjump host in ssh doesn’t quite work like that. It effectively logs into the jump host, then forwards a port to the target server and logs you in via that. So you need to put the public key from your machine in the authorized_keys file on both the jump hosts (jump1 and jump2) and the target server (login1).

Let me know if that’s not clear, I’m not sure I interpreted your question correctly.

d00phy,

Thanks! That worked. Didn’t know about the “-A” option for new.

lurch,

this is a lot of text, but the important part, an error message, is missing.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • devops@programming.dev
  • kavyap
  • thenastyranch
  • everett
  • DreamBathrooms
  • ethstaker
  • magazineikmin
  • cubers
  • Youngstown
  • tacticalgear
  • Durango
  • slotface
  • ngwrru68w68
  • rosin
  • osvaldo12
  • JUstTest
  • InstantRegret
  • cisconetworking
  • GTA5RPClips
  • modclub
  • tester
  • mdbf
  • khanakhh
  • normalnudes
  • Leos
  • megavids
  • anitta
  • provamag3
  • lostlight
  • All magazines