When working with remote desktop sessions in Linux, especially nested ones (like RDP inside Citrix), typing passwords can be challenging. Special characters and capital letters often don’t transmit correctly, leading to frustrating login attempts. This guide presents a robust solution using ydotool that handles all password characters correctly, even in nested remote sessions.
The Challenge
Common issues when typing passwords in remote sessions include:
- Shift key states not being properly recognized
- Special characters getting mangled
- Inconsistent behavior with capital letters
- Characters being dropped or misinterpreted
The Solution
Our solution uses ydotool
, a modern input automation tool for Wayland. The script we’ve developed handles every possible password character correctly by:
- Explicitly defining which characters need shift
- Processing input character by character
- Adding small delays to ensure reliability
- Resetting modifier keys before starting
Here’s the complete script (in txt otherwise it breaks this CMS ;))
How It Works
Let’s break down the script:
- Initial Setup
sleep 2s
: Gives you time to focus the correct windowydotool key 42:0 54:0 29:0 97:0
: Resets all modifier keys (left/right shift and ctrl)
- Character Sets
NO_SHIFT_CHARS
: Defines all characters that don’t require shiftSHIFT_CHARS
: Defines all characters that do require shift
- Input Processing
wl-paste
: Gets text from clipboardgrep -o .
: Splits into individual characterswhile IFS= read -r char
: Processes each character while preserving whitespace
- Character Handling
- For shift characters:
- Press shift
- Type character
- Release shift
- Small delay between actions
- For non-shift characters:
- Type character directly
- Small delay after
- For shift characters:
Usage
- Copy your password to the clipboard
- Run the script
- Click in the password field within 2 seconds
- Watch as your password is typed perfectly, character by character
Why This Works
This approach is superior to simple clipboard pasting or basic automation because:
- It handles every character explicitly and correctly
- The small delays ensure reliable transmission in nested sessions
- The modifier key reset prevents state issues
- It works consistently across different remote desktop setups
Requirements
- Linux with Wayland
- ydotool installed
- wl-clipboard installed
Security Considerations
While this script makes password entry more reliable, remember:
- Clear your clipboard after use
- Don’t store the script with your actual passwords
- Be aware of your surroundings when using it
Common Use Cases
This solution is particularly useful for:
- Complex passwords in nested remote sessions
- Environments where clipboard paste is disabled
- Situations requiring reliable special character input
- Multiple remote desktop layers
Conclusion
This script provides a reliable solution for password typing in Linux, especially in complex remote desktop scenarios. By explicitly handling each character type and adding appropriate delays, it ensures consistent and correct password entry every time.
Happy type ehh pasting 😉