I have two machines: Host1 and Host2 that are connected to the public internet but they are also connected through a private LAN (so both hosts have a public IP and a private IP).
- Host1: 192.168.0.1
- Host2: 192.168.0.2
I need to automate an SSH session from Host1 to Host2 (i.e. no password prompt). But due to security reasons I need this (the automated login) to work just for a specific user trying to connect through the private LAN only.
if user john@Host2 is trying to connect from Host1 through the private LAN (i.e. the connection is coming from 192.168.0.1), then allow that connection to use some sort of authentication key and don't prompt for a password.
If the connection is not coming from the private LAN, then don't allow an automated login (i.e. a password must be entered).
I'll appreciate some detailed directions on how to set this up.
Looking at the links given, what I've seen so far is that every solution requires to manually enter some kind of security key either at login time (for the ssh-agent thing) or after rebooting the machine (when using keychain).
Is it actually possible to automate an SSH session that works no matter if the machine has been rebooted or not?
I'm starting to believe the only way is automatically entering the password using some tool when SSH requests it... and problem solved.