m1gin 494

#ssh #vnc #reversedesktop #sharescreen #reversesharescreen #ubuntu #linux #socks #proxy #teamviewer

Remote Desktop Control

http://ubuntuforums.org/showthread.php?t=1255515&page=2

Port yönlendirmeye ihtiyaç duyulmadan uzaktaki bilgisayarın kullanılabilmesi için aşağıdaki uygulamalar kullanılabilir.

  • gitso - port 5500 forwarding needed (?)
  • Teamviewer
  • Skype - sadece ekran görüntüsü
  • Hangsout - Sharescreen: View only


Reverse SSH:

http://blog.mbirgin.com/?c=page&ID=702&t=reversesshaccessingwithoutportforwarding

Android tablette 2223 portu ile sshdroid çalıştırılıp, ConnectBot ile localhost 'a bağlandıktan sonra aşağıdaki gibi bir komutla uzak bilgisayara ters ssh ile bağlanılabildi.

ssh -R 4444:localhost:2223 m1@192.168.1.33 -p 2222

Ardından bilgisayarda şu şekilde tablete erişilebildi:

ssh root@localhost -p 4444


VNC

Port yönlendirmesi yapılmış bir bilgisayara şu şekilde bağlanmak mümkün.

Sunucu:

x11vnc -rfbport 5500

Client:

xvncviewer host.mbirgin.com:5500

Options For Slow Connection:

  • xvncviewer host.mbirgin.com:5500 -LowColourLevel 0
  • xvncviewer -listen -LowColourLevel 0 -ZlibLevel 9 -PreferredEncoding ZRLE
  • xtightvncviewer -listen -compresslevel 9
  • xtightvncviewer -listen -compresslevel 9 -encodings "tight copyrect" -quality 0
  • xtightvncviewer -compresslevel 5 -encodings "tight copyrect" -quality 5 localhost:2
  • x11vnc -rfbport 5500 -ncache 10 -solid black -geometry 1024x768

http://www.karlrunge.com/x11vnc/faq.html#faq-slow-link
https://www.tightvnc.com/vncviewer.1.php
https://www.tightvnc.com/archive/compare.html


Reverse Remote Desktop

Bağlanılacak bilgisayarda port yönlendirmesi sorunu bulunuyorsa bu yöntem kullanılabilir.

Bağlanacak bilgisayarda (ör: local.mbirgin.com)

xvncviewer -listen

komutu çalıstırılır ve aktif bırakılır. 5500 portu bu bilgisayara yönlendirilmiş olmalıdır.

Bağlanılacak bilgisayarda

x11vnc -connect local.mbirgin.com:5500

komutu çalıştırılınca; bağlanan bilgisayar, bu bilgisayarın ekranını görür ve kontrol edebilir.

Sadece izleme amaçlı ise:

xvncviewer --listen --viewonly=1 --fullcolor

veya sunucu taraflı

x11vnc -connect local.mbirgin.com:5500 -viewonly

Real VNC Viewer veya benzeri uygulamalar da kullanılabilir.

./VNC-Viewer-5.0.0-Linux-x64 -listen -Scaling=Aspectfit

http://ubuntuforums.org/showthread.php?t=1255515

http://tinyapps.org/docs/vnc/


VNC Over SSH

[By SSH …] can also listens on a particular port on your local machine, and forwards that down the secure connection to a port on a machine at the other end. For example,

ssh -L x:localhost:y snoopy

means "Start an SSH connection to snoopy, and also listen on port x on my machine, and forward any connections there to port y on snoopy."

http://www.cl.cam.ac.uk/research/dtg/attarchive/vnc/sshvnc.html

Görüldüğü üzere, ssh ile uzak bilgisayarın portu yerel bilgisayara yönlendirilebilmektedir!

Bir bilgisayara SSH üzerinden masaüstü bağlantısı yapmak için hedef bilgisayarda bir X desktop oturumu açılmış olmalıdır. Açıksa değilse

  • vncserver -geometry 1111x666
  • vncserver :0 -geometry 1111x666 -depth 16

Bu komutla bir oturum oluşturulmuş olur ve sonuçta bir port/display numarası verilir. 5900, 5901 gibi olan bu portu yerel bilgisayara yönlendirmek için:

ssh m1@lnx.4yon.org -L 5900:localhost:5900

Ardından VNC viewer ile bağlanılır:

vncviewer localhost:5900

Bu sayede hedef bilgisayarda (lnx.4yon.org) 5900,5901,5902... gibi portları açık tutmaya gerek kalmaz.


Desktop Sharing via Reverse SSH

Reverse SSH ile bağlanmış bir bilgisayara da uzak masaüstü bağlantısı kurmak mümkün.

Port yönlendirmesi yapılmamış/güvenlik duvarı arkasındaki bilgisayarda şu komut çalıştırılır.

ssh -R 12345:localhost:22 m2@local.mbirgin.com -p 2222

Daha sonra ssh reverse ile bağlanılan bilgisayarda (local.mbirgin.com) şu komut çalıştırılır.

ssh g@localhost -p 12345 -L 8888:localhost:5900 "x11vnc -display :0 -geometry 1111x600"

Bu sayede 5900 portu 8888 'e yönlendirilir ve çalıştırılan x11vnc … komutuyla 5900 portuna veri aktarımı yapılır.

Ve ardından şu şekilde izleme yapılabilir.:

vncviewer localhost:8888


Forwarding Multiple Ports Over SSH:

  • ssh m1@lnx.4yon.org -p 2222 -L 8888:localhost:8080 -L 5900:localhost:5900
  • ssh root@172.106.75.85 -p 2222 -L 5902:localhost:5902 -R 8090:localhost:8090


SSH Tunneling and SOCKS proxy.

ssh -D 9999 -C root@xen.4yon.org -p 2222

Open firefox Connection settings and set the below parameters:

SOCKS host: localhost
Port: 9999

And start browsing.
This way, no needing any proxy server to be installed on remote host.


Launch TeamViewer over SSH

$ screen veya tmux #gerek yok gibi:
$ echo $DISPLAY
$ export DISPLAY=:0.0
$ teamviewer --info
$ teamviewer

Not: Bu sırada ffmpeg/ffserver ile ekran görüntüsü izlendiğinde, grafik arayüzünün açıldığı görülmüştür.


Copy-Paste on VNC

To copy paste on tightvnc, Install to the server:

sudo apt-get install autocutsel

And run:

autocutsel -fork

For Autorun add the command in the following file:
~/.vnc/xstartup

m1gin 0

I needed to access a computer that behind firewall and uncontrolled router. So, I can't do port forwarding. 
The computer on behind firewall is Ubuntu and I want to access it from CentOS that I can control it.

After searching a lot, I realized there is "reverse SSH" technique that accomplish this. 

Here is the steps I followed.

Step 1: I installed openssh server on the computer (Ubuntu) that I want to access later.

sudo apt-get install openssh-server

Step 2: From Ubuntu I connect to Centos with following:

ssh -R 12345:localhost:22 anuser@CentOSIP

We can use another unused port instead of 12345

Step 3: If the login on step 2 is successful, then I can access Ubuntu from CentOS by following:

ssh localhost -p 12345

or login with specified Ubuntu user

ssh anuser@localhost -p 12345

That's it! Now you can access the computer (Ubuntu) without port forwarding. 

TIP: 

We also can use CentOS (for this example) like proxy server and we can access Ubuntu from another computer. 

Firstly we need to login to CenOS server

ssh anuser@CentOSIP

After logged in CentOS that we can access Ubuntu which is behind router by following command:

ssh anuser@localhost -p 12345


How to transfer file on reverse SSH?

Connect:

$ sftp -P 12345 anuser@localhost

List files/folders:

sftp> ls

Download:

sftp> get test.zip

Upload:

sftp> put test2.zip

Download a file with resume support:

$ rsync --partial --progress --rsh='ssh -p 12345' anuser@localhost:/remote/path/test.zip  /local/path

Upload a file with resume support:

$ rsync --partial --progress --rsh='ssh -p 12345' test.zip anuser@localhost:/remote/path

More: How to Resume Download/Upload over SSH

References:


#from blog.mbirgin.com, archive, ubuntu, centos, ssh, reverse ssh, ssh without port forwarding, ssh tunneling, reverse ssh tunneling, no port forwarding

Add to: