A console for RDP
By Ricardo
A story of a bored guy playing with consoles, RDP and remote VMs.
I use VMs - a lot of VMs. Some of them are Linux, but over 70% of them are just Windows boxes. Those MS ones are usually to install Visual Studio and its dependencies, which sometimes make me wanna kill someone since they’re just too many. Since the day I started having enough RAM to do that, I began isolating those development environments into isolated machines so that my main system could have only what I need on a desktop computer: a browser and games.
Whenever I need to access those machines, I use RDP (remote desktop protocol), which is the famous “remote desktop” service on Windows. However, that usually gives me headaches. You see, my laptop runs Arch Linux with i3 as window manager. In tiling WMs you usually have that so called “Mod key”, which most of the times I like to bind to the Windows key on my laptop’s keyboard (which would be useless otherwise since I don’t even have any other OS on it anymore). However, Windows also uses that key and I use a lot of shortcuts. And then comes the tricky part: how can i3 know that the keyboard combination using its Mod key is actually a combination that should be forwarded to my RDP client?
There are multiple solutions for this. For example, on Remmina, you can click on an icon on its toolbar to forward all keystrokes to the remote machine. That works, except that sometimes the toolbar gets completely lost and goes to another workspace on i3. So if this is enabled by default, I can’t disable it, which forces me to disconnect and change the configuration. Also, I don’t feel like using the touchpad to click that button so that I can read my IM’s messages. Meh, that’s annoying.
Before using Remmina, I was actually using rdesktop
, which is a good RDP client with no GUI. Just like Remmina (which seems to use xfreerdp
nowadays and not rdesktop
, btw), it has its own issues, mostly with keyboards. Meh, I don’t care, it just works. I changed to Remmina because mainly of the GUI anyway :-)
Today I was reading the --help
of rdesktop
and I’ve found this:
-0: attach to console
I gave it a try and it was perfect: all keystrokes were being redirected to the remote machine. However, I can’t switch to my other workspaces, which sucks. But reading that word console gave me an idea: what if I ran a X on another console only for that? Would that work?
Well, after a lot of tries, weird crashes and tons of verbose messages, I managed to make it work. It’s not pretty, but it works really well. Also, this doesn’t forward the console switching shortcuts, which means I can still switch between my normal X environment and my remote machine. This is the script I came up with:
#!/bin/sh
# Keyboard layout
setxkbmap br
# Disable tapping
xinput set-int-prop "AlpsPS/2 ALPS GlidePoint" "Synaptics Tap Time" 32 0
# Terminal
exec xterm
First of all, I configure my keyboard and touchpad. Then I start xterm
. You might ask yourself why I’m starting xterm
and not going straight to rdesktop
. Well, that’s because I want to type my password and also decide which IP address I’m going to connect to. Only because of that I don’t go straight into the machine :-)
To start that, I did this:
$ startx /home/ricardo/xrdpterm -- :1
Finally, once inside xterm
, I just connect to the remote machine:
$ rdesktop -u Ricardo -p - -k pt-br -z -P -0 -g 1366x768 172.16.1.155
Et voilĂ , we have a connection! Simple, huh? Now I (and maybe you?) can work in peace with that second console! Enjoy!