Hi Chris,
I believe reverse SSH tunneling may cover what you need here. You would just need some automated way of keeping the connection up.
https://www.howtoforge.com/reverse-ssh-tunneling
Kind Regards Andrew
On 31/10/2018 18:56, Chris Green wrote:
I am looking for a way that will allow my ssh 'server' machine (desktop running xubuntu 18.04 at home) to send a file back to the client machine (laptop running xubuntu 18.04 which may be anywhere including behind a firewall etc. and behind NAT).
I need the server machine to be able to do this from a script running on the server at some indeterminate time after the ssh connection has been made.
The only remotely possible way I can think of to do this is to run something via the 'LocalCommand' option in the client ssh configuration. However, at the moment, that's about as far as I can get. I can't think of a way of actually doing it at the moment.
The best I can come up with is to have a script (run as a LocalCommand) that uses sshfs to mount a server directory on the client. Then a server script can simply copy a file to the mounted directory and it will be visible on the client. Job done..., or not.
There are problems with this however. Firstly as I often have several ssh connections running at the same time there needs to be some way to prevent the LocalCommand running multiple sshfs instances. This isn't too bad to overcome but the second issue is how to pull down the sshfs connection when the last ssh exits, at present I can't see any way to do this, there isn't the equivalent of LocalCommand which runs when a connection is about to be closed.
Does anyone have any ideas which might help?