linux - How to automate a vnc+ssh solution -
i run application (call firefox) on work machine. problem need complicated ssh tunelling access access machine blocked outside , ports blocked internally. following.
ssh -v -l 1200:serverc:22 user@serverb (locally) ssh -v -l 5900:127.0.0.1:5900 -p 1200 user_from_serverc@127.0.0.1 (locally) x11vnc -safer -localhost -nopw -once -display :0 (on serverc) vinagre localhost::5900 (locally)
i run firefox (say) in vnc window opens , works.
however have bash script me. how can automate it?
there 2 problems.
- i need stay logged in after each ssh above tunelling work simple bash script stops after first step.
- i don't know how application run automatically in vnc window.
ideally type "./remote-firefox" (for example) locally happen.
try:
x11vnc -safer -localhost -nopw -once -display :0 #run manually on system_c
& on local system,
ssh -t -l 5902:localhost:5901 user_b@server_b 'ssh -t -l 5901:localhost:5900 user_c@server_c' & #note: enable password-less (key based) authentication "your_pc -> servb" & "servb -> servc" vncviewer localhost:2 #run on local system
note: if commands fail, please try changing port numbers. in example, trying tunnel below:
your_pc:5902 <-> server_b:5901 <-> server_c:5900
i have not tested 2 level chain (i not know if x11vnc's -display
parameter works across ssh, think, should.):
#run both lines on local system ssh -t -l 5902:localhost:5901 user_b@server_b "ssh -t -l 5901:localhost:5900 user_c@server_c 'x11vnc -safer -localhost -nopw -once -display :0'" & vncviewer localhost:2
edit: accomodate this:
yes that's it. annoyingly servb -> servc has port 5900 blocked. – anush
#run both lines on local system. may overhead, should work. ssh -t -l 5902:localhost:5901 user_b@server_b "ssh -t -l 5901:localhost:1200 user_c@server_c 'ssh localhost -l 1200:localhost:5900 & x11vnc -safer -localhost -nopw -once -display :0'" & vncviewer localhost:2
Comments
Post a Comment