Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can connect with this script from linux to a windows RDP session:

/usr/bin/rdesktop -N -x m -u Administrator -p secret123 -d DOMAIN1

(The rdp port of the remote windows server is securely tunneled to port 33891 on localhost)

But this script does not transmit the password properly:

/usr/bin/rdesktop -N -x m -u Administrator -p #secret$123# -d DOMAIN2

How do I have to encode the special chars in the password?

I am also wondering if it makes a difference if I choose /bin/sh as the shell for the script.


I found out this works:


share|improve this question
up vote 2 down vote accepted

I would recommend that you store the password in a file and pass it to rdesktop through a pipe. That way, the password won't show up as an argument in the command line when running ps or similar.

cat secretfile | /usr/bin/rdesktop -N -x m -u Administrator -p - -d ...

To answer your question, however, simply quoting the argument may be enough to make it work:

/usr/bin/rdesktop -N -x m -u Administrator -p '#secret$123#' -d ...


To use a variable (the value will be visible in output from ps):

/usr/bin/rdesktop -N -x m -u Administrator -p "$var" -d ...


var=$(<secretfile)    # read from a file (doesn't work in sh)
/usr/bin/rdesktop -N -x m -u Administrator -p "$var" -d ...
share|improve this answer
Would it also somehow be possible to use a bash/shell $variable instead of the secretfile? – mit Nov 2 '10 at 18:41
@mit: See my edit. – Dennis Williamson Nov 2 '10 at 21:06
How about something like var='#secret$123#'; echo $var > /tmp/secretfile; cat /tmp/secretfile | /usr/bin/rdesktop ... ; rm /tmp/secretfile ; ? – mit Nov 3 '10 at 17:01
@mit: Why use the temporary file? You could pipe the echo into the rdesktop command without the file. – Dennis Williamson Nov 3 '10 at 18:41
I was looking for a solution that does not make visible the password in the output of ps – mit Nov 4 '10 at 0:59

Special characters need to be escaped with a '\' in the Linux command line.

You can post your password and I'll show you how it should look. ;) Kidding... of course.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.