Jinshu Peethambaran
LinkedInAbout Me
  • AWS
    • Disable SSH Timeout on EC2
    • Deploy Amazon ElastiCache, a fully managed Redis service
    • Elastic Cache: Redis Connectivity from the Internet
    • Exporting AWS WAF Logs to Splunk via S3
    • Add new user to EC2 Instance
  • Zero Trust
    • Zero Trust in Database Security - Overview and Key Considerations
    • Zero Trust for Datacenter Workloads
  • Engineering
    • Change RDP Session Time Out
    • RegEx for Sensitive Data
  • Miscellaneous
    • Automated Deployment - Apache Guacamole
    • Characters allowed in a domain name
    • Automated installation of Nuclei on a MAC/Linux
    • Upload local directory codes to a new GitHub repository
Powered by GitBook
On this page

Was this helpful?

  1. Engineering

Change RDP Session Time Out

The default session timeout for Remote Desktop Protocol (RDP) sessions in Windows can vary depending on the version of Windows and any specific configurations set on the system. In general, the default session timeout for RDP is around 10 minutes of idle time.

To configure the session timeout to 2 hours, you can follow these steps:

  1. Connect to your Windows desktop running via RDP.

  2. Open the Local Group Policy Editor by pressing the Windows key + R, typing "gpedit.msc" (without quotes), and hitting Enter.

  3. In the Local Group Policy Editor window, navigate to the following path on the left-hand side: Computer Configuration -> Administrative Templates -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host -> Session Time Limits.

  4. On the right-hand side, locate the policy named "Set time limit for active but idle Remote Desktop Services sessions" and double-click on it.

  5. In the policy settings window that appears, select the "Enabled" option.

  6. Set the time limit to 120 minutes (2 hours) by entering "120" in the "Minutes" field.

  7. Click "Apply" and then "OK" to save the changes.

  8. Close the Local Group Policy Editor.

After applying these settings, RDP sessions should have a timeout of 2 hours of inactivity. Remember to test the new session timeout to ensure it functions as expected.

Note: Modifying group policies and system configurations can have implications on system behavior. It's always recommended to thoroughly test any changes in a non-production environment or consult with your system administrator before making modifications.

Here's a PowerShell script that can be used to configure the RDP session timeout to 2 hours:

# Import the necessary module for Group Policy management
Import-Module GroupPolicy

# Define the session timeout value in minutes
$sessionTimeout = 120

# Get the local Group Policy object
$localGPO = Get-WmiObject -Namespace "Root\RSOP\Computer" -Class RSOP_Session -Filter "ResultantOf='lgpo.exe'" | Select-Object -First 1

# Create a new session timeout setting
$timeoutSetting = New-Object -ComObject "GroupPolicy.GPRegistryValue"
$timeoutSetting.Key = "Software\Policies\Microsoft\Windows\SessionManager\Configuration"
$timeoutSetting.ValueName = "MaxIdleTime"
$timeoutSetting.Type = 1
$timeoutSetting.Value = $sessionTimeout

# Apply the new setting to the local Group Policy object
$localGPO.PolicyRegistrySettings.Add($timeoutSetting)
$localGPO.Put_()

# Force an update of Group Policy settings
gpupdate /force

To use this script, follow these steps:

  1. Open a text editor and paste the above script into a new file.

  2. Save the file with a .ps1 extension (e.g., configure-session-timeout.ps1).

  3. Open PowerShell with administrative privileges.

  4. Navigate to the directory where you saved the script.

  5. Run the script by executing the command .\configure-session-timeout.ps1.

The script will modify the local Group Policy object to set the RDP session timeout to 2 hours (120 minutes) and force an update of the Group Policy settings using gpupdate /force. Please note that modifying group policies can have system-wide effects, so it's recommended to run this script on a test environment or consult with your system administrator before applying it to production systems.

PreviousZero Trust for Datacenter WorkloadsNextRegEx for Sensitive Data

Last updated 2 years ago

Was this helpful?