Ubuntu – Managing multiple servers behind a firewall with SSH reverse tunnel

remote-accesssshtunnelUbuntu

I have 10 Ubuntu servers in different locations, behind a firewall each (local_server_1 to 10).
All those servers are authorized to SSH into my public server (lets call it master) using ssh keys (in other words, their ssh keys are in master's authorized_keys file).

I'm trying to create a tool which allows me to open an ssh tunnel remotely.
Each of these local servers run a php script that pings my master server, and it returns a json. If the json has this server's name in it, it runs this command:

ssh -t -t -R 13337:localhost:22 root@<master_id>

(with php's exec())

When I run this PHP myself through the command line, the tunnel opens and I can work properly.
When I run this PHP script using crontab OR supervisord, I get this error:

Host key verification failed

Any idea how I can resolve it?

Perhaps you have better solution for the issue?

Best Answer

You are probably running the command in root's crontab (did you edit the crontab file in super user mode - i.e. did you edit the crontab prepending sudo ?).

If that is the case then the host verification keys should be located in your super user's /root/.ssh/ directory, instead of yours.