0
I'd like to be able to modify ssh_config aliases based on my current IP address.
I have a laptop which I carry around from network to network, and a camera which I do the same with. I have setup the dhcp on these networks to always give the camera the same IP address, and I calculate what it should be in my bashrc and put the camera IP into an environment variable.
Is there any way to do something like the following inside ~/.ssh/config:
Host camera
HostName $CAMERA_IP
User camuser
The above doesn't work as ssh complains:
ssh: Could not resolve hostname $CAMERA_IP: Name or service not known
you could just add an alias in your hosts file ... instead of the ssh_config – Paul Bastide – 2014-01-31T13:15:53.133
But I want to do it based on my IP. I don't think the hosts file is aware of my user's environment either is it? – Sandy Patterson – 2014-01-31T13:21:23.677
you can just alias it. add an entry like IP camera – Paul Bastide – 2014-01-31T13:21:47.460
Yeah, but if I get the ssh alias's to work I get scp and rsync aliases all too. – Sandy Patterson – 2014-01-31T13:24:42.657
it'll all work if you just reference camera – Paul Bastide – 2014-01-31T13:25:15.007
I'm not sure I understand, you want to create aliases like sshcamera and scpcamera to work around modifying ~/.ssh/config? – Sandy Patterson – 2014-01-31T13:26:27.367