On 20/09/14 13:19, Chris Green wrote:
As I move around from home to various other places different systems that I connect to from my laptop become 'local'. Being a lazy person I really don't want to type in long complicated ssh commands when I'm connecting remotely. Thus I have in the ~/.ssh/config file the following:-
Host cheddar HostName cheddar.halon.org.uk Host halon HostName cheddar.halon.org.uk Host chris ProxyCommand ssh cheddar nc -q0 zbmc.eu 22 Host odin ProxyCommand ssh cheddar nc -q0 localhost 51234
This means I can simply type 'ssh chris' or 'ssh odin' and ssh with the above config file does all the hard work for me.
However it means that when I'm at home for example (where 'chris' is my desktop on the LAN) if I type 'ssh chris' I get connected to my desktop machine via the internet which is rather ridiculous.
Can anyone come up with an easy way to change how 'ssh chris' acts according to whether I'm on the LAN where 'chris' is or not. Similarly I want the same to happen when I'm on the LAN where 'odin' is (which is not the same LAN).
To me the answer to so many recent questions seems to be "Use dnsmasq"!
I have a laptop and a server. The server runs dnsmasq which does dns for my network. The server has a hosts file which is fairly normal but also has an entry like
192.168.1.100 MyServer.ItsPublicInternetAddress.Example
If my laptop is on my network and getting addresses from dnsmasq, then
ssh MyServer.ItsPublicInternetAddress.Example
is equivalent to
ssh 192.168.1.100
If my laptop is not on the network, and it's getting names from an ISP's dns server then
ssh MyServer.ItsPublicInternetAddress.Example
resolves to the true internet name of the server, and it will be accessed via the internet.
HTH Steve