96 lines
8.2 KiB
Plaintext
96 lines
8.2 KiB
Plaintext
|
|
Episode: 1710
|
||
|
|
Title: HPR1710: Windows Remote Desktop on GNU/Linux
|
||
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1710/hpr1710.mp3
|
||
|
|
Transcribed: 2025-10-18 08:06:32
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
This is HPR episode 1,710 entitled Windows Remote Desktop on New Linux and is part of the
|
||
|
|
series bash scripting. It is hosted by Ken Fallon and is about 11 minutes long. The summary is
|
||
|
|
a rapper script force-friared to make connecting to Windows server's painless.
|
||
|
|
This episode of HPR is brought to you by an honesthost.com.
|
||
|
|
Get 15% discount on all shared hosting with the offer code HPR15. That's HPR15.
|
||
|
|
Better web hosting that's honest and fair at An Honesthost.com.
|
||
|
|
Hi everybody this is Ken Fallon and I'm trying out easy voice recorder pro on my Android form
|
||
|
|
for this episode. I want to do a quick episode about Windows Remote Desktop from a
|
||
|
|
new Linux machine. I have a script that's been evolving. A bash script obviously that's been
|
||
|
|
evolving for quite some time and I thought now would be a good turn to share that with you.
|
||
|
|
I have a few different requirements. First of all I want to just be able to type the name of the
|
||
|
|
server on the console and it should pop up. Then regardless of what screen configuration I'm using,
|
||
|
|
I wanted to be 90's. I want the screen to always fit on whatever screens I have available.
|
||
|
|
So on my little laptop I wanted to be 90% smaller than the horizontal and vertical size of the
|
||
|
|
laptop screen but on my desktop where I have two screens multi-screen environment, you know two
|
||
|
|
of different sizes. I wanted so that if I move it from one screen to the other one it'll fit
|
||
|
|
on the smallest one whichever that happens to be. So it'll take the smallest height and the smallest
|
||
|
|
width and use that as they screen size and then work 90% of that. As we're here in Europe I'm
|
||
|
|
going to work across different countries. The keyboards that are plugged into the servers on the
|
||
|
|
other side could be as dirty or any combination of strange keyboards so I always wanted to map
|
||
|
|
the US keyboard. I want to map a local disk myself so that I can copy files over and back and
|
||
|
|
it shouldn't wait forever so if the board's not available it should basically time out if I
|
||
|
|
haven't connected the firewall or something like that. The full script is available on the website
|
||
|
|
and we'll be linked to in the show notes for this episode but I'll just basically go through it
|
||
|
|
very quickly and as with all of these recommendations you can if you have other recommendations
|
||
|
|
or fixes please send them on and I'll incorporate them in if it makes sense to me. So the first line
|
||
|
|
costs calls bash and the second one's we set two variables one as a server and he's in base name
|
||
|
|
$0 which is a thing type I learned from the links a lot of links links podcasts deviates I'm still
|
||
|
|
using that thanks Dave and then I set my port to 3389 which is the port number that RDP uses
|
||
|
|
and then we do that horizontal vertical size trick and what I'm using is the command called x
|
||
|
|
r and r which is command line program to get the various different settings so I use
|
||
|
|
that to find out what my current screen configuration is and I use oxort heading and bc command to
|
||
|
|
do the calculations for that and I set a variable called size with a horizontal and vertical
|
||
|
|
size so that's what that is. Then I set three other variables the password username and work group
|
||
|
|
although in actual practice I have the thing ask me for my password but here's an example of how
|
||
|
|
you could do that then I have a case statement now that I know the server name has the server
|
||
|
|
name is the name of the script it will attempt to parse through the server name so most companies
|
||
|
|
have a you know they will have us servers beginning with us or Dutch servers beginning with NL
|
||
|
|
for Netherlands or you might have lab servers beginning with lab or whatever so you can use
|
||
|
|
regular expressions in the case statement so asterix server asterix will will match any server name
|
||
|
|
that begins with that has the word server in it and then asterix colo asterix is any server that
|
||
|
|
has the word colo in it and then you're going to also just put in some server and then there you
|
||
|
|
can set individual password username so rock groups are perhaps you might want to switch keyboards for
|
||
|
|
that particular server so at the end of that we have the bash command timeout space one and then
|
||
|
|
I call bash dash c and I echo dev TCP the server in the port and this is a quick trick within bash
|
||
|
|
to find out if TCP port is open the timeout command will terminate whatever it's calling after one
|
||
|
|
second if it doesn't receive a reply if you don't do that if you don't do that the thing will time
|
||
|
|
my goal here was to make sure that I'm not waiting around forever so I'll either have a connection
|
||
|
|
or it won't so there's no point by default but I think it'll wait something like 15 minutes to
|
||
|
|
timeout and other solutions like pingings don't really work because firewall rules will prevent ping
|
||
|
|
from going through while the port itself might be open so this is a nice way of just quick
|
||
|
|
taking action to the port and moving on for the actual remote desktop session itself I stopped
|
||
|
|
using the program or desktop because there's essentially a lot of bugs now in newer versions
|
||
|
|
of rdp that haven't been fixed these we can connect with rdp version six or newer are some of the
|
||
|
|
SSL protocols they're not accepting certs so I switched to use an x3 or dp and this is the
|
||
|
|
client behind the rmia or emm i and rmina program so all I do there is then calls that
|
||
|
|
program first of all if the port is open then I call the x3 rdp forward slash v colons the
|
||
|
|
server name forward slash size we'll have the size forward slash kbd dash type and a hex string
|
||
|
|
for the keyboard type and then dash t for the server slash t colon for the workgroup slash u
|
||
|
|
colon for the username slash u colon for the password slash a which is an add-on colon drive comma
|
||
|
|
pc as much as choose colon comma and the path that I want to map in this case the root drive slash
|
||
|
|
and then space forward slash cert dash ignore and then the ampersand to send it into the background
|
||
|
|
it's a fairly odd from a unique point of view that uses forward slash is instead of the default
|
||
|
|
plus minus sign but the if you type x3 or dp you'll just see that there as well so to do the
|
||
|
|
sim linking you've got to make sure that the host names are in your dns or in your host file
|
||
|
|
and your host file is located in slash etc slash host writeable by root and there you will have
|
||
|
|
an ip address space one or more names for the servers so for um so you modify download the script
|
||
|
|
modify it and save it somewhere like use a local bash which is public or put it in your bin
|
||
|
|
directory if you don't have when you can create one and then you do a link from where it is to
|
||
|
|
where you want the sim link to be so in our example we have some have in our host file 192168
|
||
|
|
dot one dot one space some on just core servers the name of a server and then we type
|
||
|
|
lin ln space dash s for symbolic link forward slash user local bash forward slash rtp the
|
||
|
|
bash which is the name i get it and then i make the sim link into tilde which my home directory
|
||
|
|
forward slash bin forward slash some server um you need to make that
|
||
|
|
executable using um CH mod space plus x space tilde forward slash bin forward slash some server
|
||
|
|
and then once you type some underscore server it's now an executable script which will find out
|
||
|
|
that it's called some server and will attempt to connect to the server some server over x free
|
||
|
|
rdp and when you do that you'll find that your drives map and it's 90% of the screen size and pretty
|
||
|
|
much always happiness okay that's it for now i hope you enjoyed the show and i hope the quality
|
||
|
|
of this is up to snow you've been listening to hecka public radio at hecka public radio dot one
|
||
|
|
we are a community podcast network that releases shows every weekday Monday through Friday
|
||
|
|
today's show like all our shows was contributed by an hbr listener like yourself
|
||
|
|
if you ever thought of recording a podcast then click on our contribute link to find out
|
||
|
|
how easy it really is hecka public radio was founded by the digital dog pound and the
|
||
|
|
infonominant computer club and it's part of the binary revolution at binwreff.com if you have
|
||
|
|
comments on today's show please email the host directly leave a comment on the website or record
|
||
|
|
a follow-up episode yourself unless otherwise status today's show is released on the creative
|
||
|
|
comments attribution share a like 3.0 license
|