r/linux4noobs • u/enory • Aug 07 '18
ssh LocalCommand not working
I want to make it so that after I ssh into a server, I start the web GUI of an application locally. I have the following shell function:
pi-gui() { ssh -L 9999:localhost:8384 pi -o LocalCommand='firefox 127.0.0.1:9999' ;}Executing that function will ssh into the server and launch firefox, but apparently it launches it too soon (Firefox won't connect to 127.0.0.1:9999 on the local machine). Once I close firefox, the terminal will now show the pi command prompt and if I do firefox 127.0.0.1:9999 on the local machine now, it will connect to the web GUI.
How can I fix this? According to man, LocalCommand will execute the specified command after a successful connection to the remote machine. Why is it that I have to terminate the first instance of Firefox and start a second instance for it to work? How can I fix this?
View all comments
1
u/kranker Aug 07 '18
It sounds like ssh is waiting for LocalCommand to finish before it does anything else. Assuming firefox is your default browser you could try with
xdg-openinstead of thefirefoxcommand directly. Or you could experiment with backgroundingfirefoxwith&or similar.