Archive of

Windows Server 2022 RDP Connection Fix

Problem

  • Our IT security team has weird security setup, which successfully prevented the RDP client from remembering the password, and also caused the following annoying issue

    • RDP connection requires clicking "More choices" → "Use a different account" every time
    • Username not remembered despite saving in RDP file

Solution

Edit your .rdp file with these key settings:

full address:s:your-server-address, such as xetawsdev85.xemt.dev 
domain:s:XEMT 
username:s:your-username, such as David.Wei 
enablecredsspsupport:i:0

Key Points

  1. Separate domain and username - don't use XEMT\David.Wei format in RDP file
  2. Set authentication level:i:2 - forces proper authentication (this step has been proved not necessory)
  3. Disable CredSSP support - enablecredsspsupport:i:0 is essential (tested, this is the KEY option!)
  4. If you see a certificate warning on first connection - check "Don't ask me again"

Result

Username will be pre-filled correctly, only password entry required.

网友语录 - 第39期 - 人生哪里有死结,不过是饥来餐饭,倦来眠....

这里记录我的一周分享,通常在周六发布。


有可能人这一生都无法找到所谓的真爱,所做的一切都是在有限的时间里对抗孤独和虚无。-- 《我们八月见》


人生哪里有死结,不过是饥来餐饭,倦来眠....


说真话;不能说真话的境况下,保持沉默;非说假话不可,不可伤害他人


你的孩子不想成为你,
就如同你不想成为你的父母。
朱德庸


只有大胆放手,孩子才会成长。要知道,你并不总是那么不可或缺,你不可能一直掌控一切。拥抱变化,拥抱风险。人类从来都是从亲自碰壁中长大……


阿鸭肚脐 与人相处,不要当爹,不要当妈,但也不当儿子。尊重他人命运,你看着是弯路,对人家来说也许是人生的必经路,谁说弯路就没用?谁又能保证你的意见对人家就是最好的?不理解但尊重,实在看不懂就走开,这里不是你的舞台。


非凡人生 (冯仑)

冯仑的女儿13岁生日时,向父亲要礼物。冯仑给的是15分钟的谈话时间:

“一个人, 无论男女,必须知道人生有两种,两种人生两种人。生活中95%的人是过日子、讨生活,努力工作。按照多数人的价值观一辈一辈延续社会秩序,完成种族繁衍。%5的人是挑战命运,创造未来。这种人注定要一辈子漂泊,但无论成与败都有属于自己的辉煌。

社会是大众化的,成为5%的人并非易事,脱离95%的人,相当于脱离地球引力,总会得到很多人的打击,他们不能按照常人的价值观生活。在那5%的人里,是非观、价值观与许多人都不同。生活是自己的,选择过怎样的生活要自己仔细考虑。

如果你选择做5%的人,你可能颠沛流离,含辛茹苦,最后可能得不到掌声,也可能死无葬身之地。5%的人生没有人可以教你,你必须自己相信自己心中的理想,并为自己的理想坚持奋斗。

冯仑对女儿说,要想好,如果是第一种人生,可以不用讨论,问你的爷爷奶奶,他们会告诉你;如果是第二种,我也不能告诉你要怎么做,但可以探讨。选择第二种人生的人,你可能被人议论,直到你脱离地球到卫星轨道,也就没有人议论了

Fixing Claude Code (1.0.51/1.0.45) in Git Bash

1.0.72 works well among all my terminals in Windows and Linux without any hacks. So please forget the fix in this article and try 1.0.72!
for version 1.0.51 or newer, you can simply add a new environment variable with CLAUDE_CODE_GIT_BASH_PATH=C:\Program Files\git\bin\bash.exe using Edit environment variables for your account feature on windows.

However, I stick with v1.0.45 for now, as I noticed 1.0.51 no longer support paste image in gitbash, which is a pity!

I just noticed this hack only works with version 1.0.45, so please stick with version 1.0.45 for now until we found another hack :D

Claude Code fails in Git Bash with path errors like:

Error: /usr/bin/bash: line 1: C:UsersDavid.WeiAppDataLocalTemp/claude-shell-snapshot-6ea5: No such file or directory

Root cause: os.tmpdir() returns Windows paths, Git Bash expects Unix paths.

Solution: Patch the CLI directly with sed.

# Create ~/bin/c
#!/bin/bash
REAL_CLAUDE=$(which claude)
basedir=$(dirname "$REAL_CLAUDE")
case `uname` in
    *CYGWIN*|*MINGW*|*MSYS*)
        if command -v cygpath > /dev/null 2>&1; then
            basedir=`cygpath -w "$basedir"`
        fi
    ;;
esac

CLAUDE_DIR="$basedir/node_modules/@anthropic-ai/claude-code"
CLI_FILE="$CLAUDE_DIR/cli.js"
BACKUP_FILE="$CLI_FILE.original"

# Backup once
if [ ! -f "$BACKUP_FILE" ]; then
    cp "$CLI_FILE" "$BACKUP_FILE"
fi

# Patch and run
cp "$BACKUP_FILE" "$CLI_FILE"
sed -i 's/\b\w\+\.tmpdir()/\"\/tmp\"/g' "$CLI_FILE"

cd "$CLAUDE_DIR"
exec node "cli.js" "$@"
chmod +x ~/bin/c
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc

Now works:

c doctor
c --version  

The regex catches minified variable names. Patches fresh every run, so updates don't break it.

Quick Fix: Claude Code Image Paste in Linux Terminal

Can't paste images to Claude Code in your Linux terminal? Here's a one-minute fix for Kitty users.

The Fix

1. Create the script (~/bin/clip2path):

#!/usr/bin/env bash
set -e

if [ -n "$WAYLAND_DISPLAY" ]; then
    types=$(wl-paste --list-types)
    if grep -q '^image/' <<<"$types"; then
        ext=$(grep -m1 '^image/' <<<"$types" | cut -d/ -f2 | cut -d';' -f1)
        file="/tmp/clip_$(date +%s).${ext}"
        wl-paste > "$file"
        printf '%q' "$file" | kitty @ send-text --stdin
    else
        wl-paste --no-newline | kitty @ send-text --stdin
    fi
elif [ -n "$DISPLAY" ]; then
    types=$(xclip -selection clipboard -t TARGETS -o)
    if grep -q '^image/' <<<"$types"; then
        ext=$(grep -m1 '^image/' <<<"$types" | cut -d/ -f2 | cut -d';' -f1)
        file="/tmp/clip_$(date +%s).${ext}"
        xclip -selection clipboard -t "image/${ext}" -o > "$file"
        printf '%q' "$file" | kitty @ send-text --stdin
    else
        xclip -selection clipboard -o | kitty @ send-text --stdin
    fi
fi

2. Make executable:

chmod +x ~/bin/clip2path

3. Add to ~/.config/kitty/kitty.conf:

allow_remote_control yes
listen_on unix:/tmp/kitty-socket
map ctrl+v launch --type=background --allow-remote-control --keep-focus ~/bin/clip2path

4. Install dependencies:

# X11 users only
sudo apt install xclip

5. Restart Kitty

6. Setup automatic cleanup (optional):

# Add to crontab to clean old screenshots daily
(crontab -l 2>/dev/null; echo "0 3 * * * find /tmp -name 'clip_*' -type f -mtime +1 -delete") | crontab -

Now Ctrl+V automatically saves clipboard images as temp files and pastes their paths. Works on both Wayland and X11.

网友语录 - 第38期 - 为了做自己,爱情当然可以不要

这里记录我的一周分享,通常在周六发布。


赞声与骂声,都不要在意,而要在乎自己能不能做好。把自己做好,就没有问题。


一位印度程序员2023年评论道: "有时我对 ChatGPT 的理解能力感到惊讶,但是更多时候,我不得不拼命推动它,朝着我想要的方向前进。它有时会产生意料之外的结果,让我感到非常沮丧。"

"它像一个吸收了所有人类知识、但需要别人帮忙才能把这些知识串起来的应届毕业生。"

"看来我今年的工作是安全的。但是,我需要好好学习 ChatGPT,精通它的使用,让我明年也是安全的。"

(Claude 比 ChatGPT 厉害得多,但其200k的上下文还是有点小)

…more