qns8dn3
June 10th, 2008, 03:17 PM
rdesktop is a client program that allows you to connect from your Ubuntu computer to your Windows computer to remote control the Windows computer. In other words, while you are sitting in front of your Ubuntu computer at home, you can log into and access your Windows computer as if you are sitting in front of the Windows computer. See remote desktop software (http://en.wikipedia.org/wiki/Remote_desktop_software).
rdesktop and VNC and Terminal Server Client (comparison)
There is another similar program called VNC. VNC is slow compared to rdesktop and VNC connection is unencrypted while rdesktop connection is encrypted by default. But there is a way to use VNC with encrypted connection (https://help.ubuntu.com/community/VNCOverSSH). VNC works on almost all operating systems. See comparison of remote desktop software (http://en.wikipedia.org/wiki/Comparison_of_remote_desktop_software).
Terminal Server Client (Applications > Internet > Terminal Server Client) is a GUI front-end to VNC and rdesktop. If you open Terminal Server Client, you will see Protocol option (RDP, RDPv5, VNC), RDP and RDPv5 are for rdesktop connection. You should use Terminal Server Client if it works fine and if you are ok with this bug (https://bugs.launchpad.net/ubuntu/+source/rdesktop/+bug/103208). If you want more control (such as connecting a specific local folder or other device redirection, hiding or keeping window manager decoration, using seamlessRDP), use rdesktop following this guide.
What to do on the Windows side (the server side)
The Windows computer you will connect to must be running Windows XP Pro or a higher version of Windows.
* If you have a weak Windows login password (such as john1, aaaaaaaaaaaaa, abcabc), change it to a stronger password that is longer than 10 characters and that is not a combination of words that can be found on a dictionary. You need to do this because if you enable Remote Desktop Connection, anybody with internet access can try to log into your Windows computer with automated cracking tools.
* Enable Remote Desktop Connection on the Windows computer following this guide (http://www.microsoft.com/windowsxp/using/mobility/getstarted/remoteintro.mspx). If the Ubuntu computer you will be connecting from has a static ip address, you can set your Windows Firewall to allow remote desktop connection from only your Ubuntu computer and refuse connection from other computers. To do this, open Windows Firewall, click on the Exceptions tab, Select 'Remote Desktop', click 'Edit', click 'Change Scope...', choose 'Custom list' and enter the IP addresses of computers from which you want to remote connect (See the attached screenshot)
What to do on the Ubuntu side (client side)
* On your Ubuntu computer, open a terminal (Application > Accessories > Terminal) and enter the following command:
rdesktop
You'll see a long list of options for rdesktop. Think of it as an rdesktop cheatsheet.
If your windows username and Ubuntu username is the same and if the static IP address of your Windows computer is (suppose) 143.210.123.456, you can now connect to your Windows computer by entering the following command:
rdesktop 143.210.123.456
If the usernames are different and your Windows username is (suppose) john, enter:
rdesktop -u john 143.210.123.456
To disconnect, open Windows Start menu and click 'Disconnect'.
Most cases, you'll use one of the following two commands:
rdesktop -u john -fP 143.210.123.456
rdesktop -u john -g 100% -PKD 143.210.123.456
Both commands display remote desktop in full screen (corresponding option : -f, -g 100% -D) and bitmap cache is enabled for speed (-P). There is a bug and clipboard functionality (copy paste between remote desktop and local one) doesn't work in full screen mode (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=335544). To make clipboard work, you need to escape full screen mode by pressing ctrl+alt+enter. ( Press ctrl+alt+enter again to get back to full screen mode. ) This bug only affects the first command and not the second command. So if you need to copy and paste between two desktops a lot, go with the second command. (Install dragking (http://www.donationcoder.com/Software/Skrommel/index.html#DragKing) if you want to copy by selecting a text and paste by middle-click on your Windows desktop. dragking.ahk script requires ahkstructlib.ahk (http://www.autohotkey.com/forum/viewtopic.php?t=4888)). The two commands also differs in how the keybindings are handled,
* First command : if you press alt+tab (keyboard shortcut for switching windows), it doesn't switch windows from Ubuntu desktop, it switches from the remote Windows desktop. And ctrl+alt+right (for switching to another workspace) doesn't work. This is useful when you want to alt+tab in the remote Windows.
* Second command : keyboard shortcuts such as ctrl+alt+right and alt+tab works on your Ubuntu desktop. This is useful because you can put the remote desktop on the seperate workspace then you can switch between your local ubuntu workspace and your remote Windows desktop just by pressing ctrl+alt+right and ctrl+alt+left.
Create a launcher
Opening terminal every time you want to remote connect to Windows is of a hassle. To create a lancher, right click on the top panel, click 'Add to Panel...', select 'Custom Application launcher', click 'Add' button, type your command in the command field. (See the attached screenshot). if the command contains %, replace % with %%.
useful rdesktop options
-r disk:doc=/home/john/Documents,pic=/home/john/Pictures
With this option, rdesktop connects folders /home/john/Documents and /home/john/Pictures to Windows remote desktop. Open Windows Start menu and click 'My Computer' and you will see the connected folders named doc and pic.
-r sound:local
This option is to hear sound from Windows remote desktop.
See /usr/share/doc/rdesktop/redirection.txt for more on device redirection.
-k ko
This sets the keyboard layout to Korean. This makes Hangul key work on the remote desktop. See /usr/share/doc/rdesktop/keymap-names.txt
How to use rdesktop over ssh
rdesktop is vulnerable to man-in-the-middle attacks (http://sourceforge.net/mailarchive/message.php?msg_name=732099.24912.qm%40web45108.ma il.sp1.yahoo.com). So you might want to use it over ssh.
Follow this lifehacker article (http://lifehacker.com/software/home-server/geek-to-live--set-up-a-personal-home-ssh-server-205090.php) to set up an ssh server on the Windows computer. (You can edit sshd_config with a Windows editor supporting UNIX texts such as notepad2 (http://sourceforge.net/projects/notepad2/)) You might want to set Windows Firewall to disallow ssh access from IP addresses other than your Ubuntu computer's. Take note of the RSA key fingerprint by open a cygwin shell (Start > All Programs > Cygwin > Cygwin Bash Shell) and entering :
ssh-keygen -lf /etc/ssh_host_rsa_key.pub
On your Ubuntu computer, check if the local port 3389 (default listening port number for Windows Remote Desktop service) is available:
telnet localhost 3389
The output should be similar to :
$ telnet localhost 3389
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
, which means the port is available. If the port is already in use the output should be similar to :
$ telnet localhost 3389
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
If the port is available, connect to windows ssh service with port forward:
ssh -L 3389:localhost:3389 john@143.210.123.456
The port 3389 of your Ubuntu is forwarded to the port 3389 of your Windows. The output should be like :
$ ssh -L 3389:localhost:3389 john@143.210.123.456
The authenticity of host '143.210.123.456 (143.210.123.456)' can't be established.
RSA key fingerprint is f3:90:3b:70:20:a2:52:fe:fx:a2:90:70:3b:f3:6a:22.
Are you sure you want to continue connecting (yes/no)?
Check if the presented RSA key fingerprint is the same as the one you took note of. If they are different, you should answer no, the host you are connecting to is not your real Windows computer, it may be a man in the middle (http://en.wikipedia.org/wiki/Man_in_the_middle_attack). If they are same, answer yes and proceed. You can get out of the ssh session by entering 'exit' but don't do it now.
Open another terminal and make rdesktop connect to localhost:
rdesktop -u john localhost
The remote desktop will be a bit slow. cygwin is slow.
What if the port 3389 was already in use? Find a different available port (suppose, 3099) and connect to Windows ssh like this :
ssh -L 3099:localhost:3389 john@143.210.123.456
The port 3099 of your Ubuntu is forwarded to the port 3389 of your Windows.
Open a new terminal and make rdesktop connect to localhost at the port 3099 :
rdesktop -u john localhost:3099
rdesktop and VNC and Terminal Server Client (comparison)
There is another similar program called VNC. VNC is slow compared to rdesktop and VNC connection is unencrypted while rdesktop connection is encrypted by default. But there is a way to use VNC with encrypted connection (https://help.ubuntu.com/community/VNCOverSSH). VNC works on almost all operating systems. See comparison of remote desktop software (http://en.wikipedia.org/wiki/Comparison_of_remote_desktop_software).
Terminal Server Client (Applications > Internet > Terminal Server Client) is a GUI front-end to VNC and rdesktop. If you open Terminal Server Client, you will see Protocol option (RDP, RDPv5, VNC), RDP and RDPv5 are for rdesktop connection. You should use Terminal Server Client if it works fine and if you are ok with this bug (https://bugs.launchpad.net/ubuntu/+source/rdesktop/+bug/103208). If you want more control (such as connecting a specific local folder or other device redirection, hiding or keeping window manager decoration, using seamlessRDP), use rdesktop following this guide.
What to do on the Windows side (the server side)
The Windows computer you will connect to must be running Windows XP Pro or a higher version of Windows.
* If you have a weak Windows login password (such as john1, aaaaaaaaaaaaa, abcabc), change it to a stronger password that is longer than 10 characters and that is not a combination of words that can be found on a dictionary. You need to do this because if you enable Remote Desktop Connection, anybody with internet access can try to log into your Windows computer with automated cracking tools.
* Enable Remote Desktop Connection on the Windows computer following this guide (http://www.microsoft.com/windowsxp/using/mobility/getstarted/remoteintro.mspx). If the Ubuntu computer you will be connecting from has a static ip address, you can set your Windows Firewall to allow remote desktop connection from only your Ubuntu computer and refuse connection from other computers. To do this, open Windows Firewall, click on the Exceptions tab, Select 'Remote Desktop', click 'Edit', click 'Change Scope...', choose 'Custom list' and enter the IP addresses of computers from which you want to remote connect (See the attached screenshot)
What to do on the Ubuntu side (client side)
* On your Ubuntu computer, open a terminal (Application > Accessories > Terminal) and enter the following command:
rdesktop
You'll see a long list of options for rdesktop. Think of it as an rdesktop cheatsheet.
If your windows username and Ubuntu username is the same and if the static IP address of your Windows computer is (suppose) 143.210.123.456, you can now connect to your Windows computer by entering the following command:
rdesktop 143.210.123.456
If the usernames are different and your Windows username is (suppose) john, enter:
rdesktop -u john 143.210.123.456
To disconnect, open Windows Start menu and click 'Disconnect'.
Most cases, you'll use one of the following two commands:
rdesktop -u john -fP 143.210.123.456
rdesktop -u john -g 100% -PKD 143.210.123.456
Both commands display remote desktop in full screen (corresponding option : -f, -g 100% -D) and bitmap cache is enabled for speed (-P). There is a bug and clipboard functionality (copy paste between remote desktop and local one) doesn't work in full screen mode (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=335544). To make clipboard work, you need to escape full screen mode by pressing ctrl+alt+enter. ( Press ctrl+alt+enter again to get back to full screen mode. ) This bug only affects the first command and not the second command. So if you need to copy and paste between two desktops a lot, go with the second command. (Install dragking (http://www.donationcoder.com/Software/Skrommel/index.html#DragKing) if you want to copy by selecting a text and paste by middle-click on your Windows desktop. dragking.ahk script requires ahkstructlib.ahk (http://www.autohotkey.com/forum/viewtopic.php?t=4888)). The two commands also differs in how the keybindings are handled,
* First command : if you press alt+tab (keyboard shortcut for switching windows), it doesn't switch windows from Ubuntu desktop, it switches from the remote Windows desktop. And ctrl+alt+right (for switching to another workspace) doesn't work. This is useful when you want to alt+tab in the remote Windows.
* Second command : keyboard shortcuts such as ctrl+alt+right and alt+tab works on your Ubuntu desktop. This is useful because you can put the remote desktop on the seperate workspace then you can switch between your local ubuntu workspace and your remote Windows desktop just by pressing ctrl+alt+right and ctrl+alt+left.
Create a launcher
Opening terminal every time you want to remote connect to Windows is of a hassle. To create a lancher, right click on the top panel, click 'Add to Panel...', select 'Custom Application launcher', click 'Add' button, type your command in the command field. (See the attached screenshot). if the command contains %, replace % with %%.
useful rdesktop options
-r disk:doc=/home/john/Documents,pic=/home/john/Pictures
With this option, rdesktop connects folders /home/john/Documents and /home/john/Pictures to Windows remote desktop. Open Windows Start menu and click 'My Computer' and you will see the connected folders named doc and pic.
-r sound:local
This option is to hear sound from Windows remote desktop.
See /usr/share/doc/rdesktop/redirection.txt for more on device redirection.
-k ko
This sets the keyboard layout to Korean. This makes Hangul key work on the remote desktop. See /usr/share/doc/rdesktop/keymap-names.txt
How to use rdesktop over ssh
rdesktop is vulnerable to man-in-the-middle attacks (http://sourceforge.net/mailarchive/message.php?msg_name=732099.24912.qm%40web45108.ma il.sp1.yahoo.com). So you might want to use it over ssh.
Follow this lifehacker article (http://lifehacker.com/software/home-server/geek-to-live--set-up-a-personal-home-ssh-server-205090.php) to set up an ssh server on the Windows computer. (You can edit sshd_config with a Windows editor supporting UNIX texts such as notepad2 (http://sourceforge.net/projects/notepad2/)) You might want to set Windows Firewall to disallow ssh access from IP addresses other than your Ubuntu computer's. Take note of the RSA key fingerprint by open a cygwin shell (Start > All Programs > Cygwin > Cygwin Bash Shell) and entering :
ssh-keygen -lf /etc/ssh_host_rsa_key.pub
On your Ubuntu computer, check if the local port 3389 (default listening port number for Windows Remote Desktop service) is available:
telnet localhost 3389
The output should be similar to :
$ telnet localhost 3389
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
, which means the port is available. If the port is already in use the output should be similar to :
$ telnet localhost 3389
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
If the port is available, connect to windows ssh service with port forward:
ssh -L 3389:localhost:3389 john@143.210.123.456
The port 3389 of your Ubuntu is forwarded to the port 3389 of your Windows. The output should be like :
$ ssh -L 3389:localhost:3389 john@143.210.123.456
The authenticity of host '143.210.123.456 (143.210.123.456)' can't be established.
RSA key fingerprint is f3:90:3b:70:20:a2:52:fe:fx:a2:90:70:3b:f3:6a:22.
Are you sure you want to continue connecting (yes/no)?
Check if the presented RSA key fingerprint is the same as the one you took note of. If they are different, you should answer no, the host you are connecting to is not your real Windows computer, it may be a man in the middle (http://en.wikipedia.org/wiki/Man_in_the_middle_attack). If they are same, answer yes and proceed. You can get out of the ssh session by entering 'exit' but don't do it now.
Open another terminal and make rdesktop connect to localhost:
rdesktop -u john localhost
The remote desktop will be a bit slow. cygwin is slow.
What if the port 3389 was already in use? Find a different available port (suppose, 3099) and connect to Windows ssh like this :
ssh -L 3099:localhost:3389 john@143.210.123.456
The port 3099 of your Ubuntu is forwarded to the port 3389 of your Windows.
Open a new terminal and make rdesktop connect to localhost at the port 3099 :
rdesktop -u john localhost:3099