RDP from the Command Line

Let’s face it, connecting to Windows Servers is a must for many of us. And some of us want to do so programatically. I did look at populating the CoRD database in a previous article. But now, luckily CoRD has recently introduced a command line interface for managing just these types of connections on the fly as well. And, it is very straight forward.

There are two ways to call CoRD from the command line. The first is similar to how we handled VNC in an earlier article. Simply leverage the open command and call the URL with a rdp in the beginning. For example, if you want to open a connection to a server called windows.krypted.com you would use the following command:

open rdp://windows.krypted.com

As with VNC you can also inject he user name and the password as well. To do so insert the username after the rdp:// and with an @ before the domain or IP. And to inject the password follow the username with a : and then the password followed by the @. For example, if our username were daneel and our password were seldon then the command would be:

open rdp://daneel:seldon@windows.krypted.com

There are other options as well, which you can find at the CoRD Wiki. You can also connect by calling the CoRD command, which is located in the /Applications/CoRD.app/Contents/MacOS directory. The CoRD command then has the following options:
host – define the IP address or host name of the computer you are connecting to
port – if a custom port (not 3389) is used then use that to connect to the computer
u – define a username
p – define a password
d – Windows domain name
a – set screen depth to 8, 16, 24 or 32
width – set the width of the resultant window
height – set the height of the resultant window

So if you would like to connect to windows.krypted.com with the same user and password as before, but now with a custom port of 3390 you would use the following command:
/Applications/CoRD.app/Contents/MacOS/CoRD -host windows.krypted.com -port 3390 -u daneel -p seldon

I guess next I’m going to have to build a Dashboard widget to fire up a connection on the fly… ;)

Comments are closed.