35

I've created one RDP file

full address:s:10.20.30.40
username:s:myuser
password:s:mypassword
domain:s:mydomain

When I open this file it still asks me for the password. What can I do to tell RDP client to use password mentioned in the file instead of asking user?

7 Answers7

39

I had the issue on Windows 10 with perma asking password when I try to connect to a new machine.

First, the password line in the RDP must be named:

password 51:b:myEncryptedPassword

And the pass must by encrypted. You can use cryptRDP5 to convert it: https://github.com/jps-networks-modifiedOSS/openvpn-als-applications/tree/master/adito-application-rdp-xplatform-embedded/src/windows

cryptRDP5.exe yourpassword

Note that the generated password is only valid for the machine that did it.

Note 2: cryptRDP5 don't seems to parse correctly a password containing an apostrophe character ' Better to use Powershell as suggested in comments.

Makusensu
  • 491
11

Open the Group Policy editor (Start > Run > gpedit.msc) and navigate to Computer Configuration -> Administrative Templates -> Windows Components -> Remote Desktop Services -> Remote Desktop Connection Client

For value Do not allow passwords to be saved, check that is set to Disabled.

When connecting to a machine in Remote Desktop Connector, expand the Options panel and confirm that Allow me to save credentials is checked.

Net Runner
  • 6,319
6

I had to do all these three steps to make it not prompt for password when trying to connect using the .rdp file.

  1. Open the .rdp file in a text editor and look for the line prompt for credentials:i:1. Change the last 1 to a 0, like so prompt for credentials:i:0

  2. Generate encrypted password using this PowerShell command:

    ("MySuperSecretPassword" | ConvertTo-SecureString -AsPlainText -Force) | ConvertFrom-SecureString;
    
  3. Add a line like this password 51:b:MyEncryptedPassword in the .rdp file.

Now connecting using the .rdp file should not prompt for the password.

4

Try adding

prompt for credentials:i:0
2

I didn't managed to do this by modifying the .rdp. But a workaround is, to change the settings of the remote desktop connection application. In Preferences -> User Accounts you can add your account + password:

enter image description here

DracoBlue
  • 121
0

Here is a Python 3 program that inserts username/password into RDP file and also creates LNK file for it (to drag to quick launch, for example). It is based on several existing solutions, credits for those goes to their authors.

import sys, os, getpass, subprocess

if (len(sys.argv) != 2): print("\nRDPPassword is a Python 3 program that inserts username") print("and password into existing RDP file and creates a LNK file") print("that can be dragged to taskbar's QuickLaunch area.") print("\nUSAGE: python %s <RDP file>\n" % os.path.basename(sys.argv[0])) exit(1)

def InsertPassword(rdpfile, user, password): fileIn = open(rdpfile, "r", encoding="'utf_16_le") lines = fileIn.read().splitlines() fileIn.close() outLines = [] bPromptCredentials = False bUsername = False bPassword = False for line in lines: if line.startswith('promptcredentialonce:i:'): outLines.append('promptcredentialonce:i:1') bPromptCredentials = True elif line.startswith('username:s:'): outLines.append('username:s:%s' % user) bUsername = True elif line.startswith('password 51:b:'): outLines.append('password 51:b:%s' % password) bPassword = True elif len(line)>0: outLines.append(line) if not bPromptCredentials: outLines.append('promptcredentialonce:i:1') if not bUsername: outLines.append('username:s:%s' % user) if not bPassword: outLines.append('password 51:b:%s' % password)

fileOut = open(rdpfile, &quot;w&quot;, encoding=&quot;utf_16_le&quot;)
for line in outLines:
    #fileOut.write(&quot;%s%s&quot; % (line, os.linesep))
    fileOut.write(&quot;%s%s&quot; % (line, '\n'))
    #print(&quot;#%s#&quot;%line)
fileOut.close()

def RunShell(command): # pipes usage taken from: https://superuser.com/questions/1540516/how-do-i-execute-powershell-commands-with-pipes-in-python PSEXE = r'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' PSRUNCMD = "Invoke-Command -ScriptBlock " process = subprocess.run([PSEXE, PSRUNCMD + "{" + command + "}"], stdout = subprocess.PIPE, stderr = subprocess.PIPE, universal_newlines = True) #print("CMD", command) #print("ERR", process.stderr) #print("OUT", process.stdout) return process.stdout

if not os.path.exists(sys.argv[1]): print("\nFile '%s' not found.\n" % sys.argv[1]) exit(1)

if not ( (sys.argv[1].endswith(".rdp")) or (sys.argv[1].endswith(".RDP")) ): print("\nFile '%s' not a RDP file.\n" % sys.argv[1]) exit(1)

print("\nInserting username/password into '%s'" % sys.argv[1]) username = input("Username: ") #password = getpass.getpass("Password: ") #use this if you do not want the password to be seen while typing password = input("Password: ")

insert username/password into RDP file

**************************************

RDP password generation taken from: https://serverfault.com/questions/867467/rdp-file-with-embedded-password-asks-for-password

PassCmd = "('%s' | ConvertTo-SecureString -AsPlainText -Force) | ConvertFrom-SecureString;" % password password = RunShell(PassCmd)

InsertPassword(sys.argv[1], username, password)

create a LNK file for RDP

*************************

print("\nCreating a LNK file for '%s'" % sys.argv[1])

https://superuser.com/questions/298974/how-do-i-pin-a-remote-desktop-connection-to-the-taskbar

RunRdp = r'"%windir%\system32\mstsc.exe"' RunArgs = "'&quot;%s&quot;'" % os.path.abspath(sys.argv[1])

https://superuser.com/questions/392061/how-to-make-a-shortcut-from-cmd

LnkCmd = '$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("%s"); $S.TargetPath = %s; $S.Arguments = %s; $S.Save()' % (sys.argv[1][:-3]+"lnk", RunRdp, RunArgs) RunShell(LnkCmd)

print("\nDone.\n")

Stoopkid
  • 103
0

To enable the setting, the user can enter promptcredentialonce:i:1 in the RDP file.

If the user wants to disable the setting, then user can enter promptcredentialonce:i:0 in the RDP file.

Colt
  • 2,127