On 22/09/14 21:24, Chris Green wrote:
On Mon, Sep 22, 2014 at 08:25:10PM +0100, Adam Bower wrote:
No! Jesus, this is not hard to understand, please try.
Create in your ssh config
Host chris Hostname zbmc.eu
and then on dnsmasq on the lan where this host is put into /etc/hosts the name zbmc.eu and the IP address of the machine on the local lan. Then the DNS lookup for this machine will resolve to the local IP address.
Then you can type ssh chris and it will do the right thing.
Yes, it will do the right thing when I'm on the LAN. It will *not* do the right thing (connect via the intermediate machine) when I am connecting from elsewhere.
Maybe I'm not explaining well but when I'm connecting from elsewhere my connection isn't direct to zbmc.eu. For security I only allow connections from two specific IP addresses, one of which is cheddar.halon.org.uk.
So the procedure (in longhand) to connect from outside is:-
ssh cheddar.halon.org.uk chris@cheddar.halon.org.uk's password: halon$ ssh zbmc.eu chris@zbmc.eu's password: Last login: Mon Sep 22 19:34:18 2014 from x201.zbmc.eu chris@chris$
Thus I have added the following lines in my ssh config file:-
Host halon HostName cheddar.halon.org.uk Host chris ProxyCommand ssh cheddar nc -q0 zbmc.eu 22
These mean that I can enter 'ssh chris' from outside and it does all the work for me. However it also means that 'ssh chris' when I'm on the LAN also goes via cheddar.halon.org.uk because of the 'Host chris' line in the config file.
Another alternative, inside the LAN, just use ssh chris
for outside the lan, create a bash script and call it sshchris2.sh or something short and snappy. put all your commands in that. Then if you at home just do ssh chris, away from home just sshchris2. Simple Sorted?
Steve