Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been trying to setup some sort of configuration on my laptop , so I'd be able to connect to a server using SSH , directly , which i have indirect access to , i've found a great configuration here : http://superuser.com/a/303487/133737 so sofar i've made this configuration :

Host terzo , gw02, ipsec

ProxyCommand ssh zenoss nc -w 10 %h %p

but i want to be able to ssh to forinstance zenipsec , and it'd directly go through zenoss

I'm hoping to create something like this :

Host zen*

ProxyCommand ssh zenoss nc -w 10 %h `echo %h | cut -f2-100 -dn`

i guess the last part `echo %h | cut -f2-100 -dn` , doesn't work . can anyone help ?

share|improve this question

2 Answers 2

You are telling netcat to use zenipsec as host and ipsec as port. The following should be correct:

nc -w 10 `echo %h | cut -f2-100 -dn` %p

A much cleaner way to do this is to write a script that acts as a ProxyCommand; for example, ~/bin/proxycommand-zen

#!/bin/sh
host=$1
port=$2
exec ssh zenoss nc -w 10 ${host#zen} $port
share|improve this answer

A useful configuration which I use is this:

Host *%*
    ProxyCommand ssh $(echo %h | cut -d%% -f2-) nc $(echo %h | cut -d%% -f1) %p

It allows you to setup arbitrary hops by separating the hosts with the % sign. For example, ssh zenipsec%zenoss would hop through zenoss to get to zenipsec.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.