@@ -36,16 +36,26 @@ echo "Syncing credentials from host to VM..."
3636# Ensure .claude directory exists in VM
3737ssh " ${HOSTNAME} " ' mkdir -p ~/.claude'
3838
39+ # Copy .claude.json configuration file
40+ scp ~ /.claude.json " ${HOSTNAME} :~/.claude.json"
41+
3942# Extract and copy credentials based on host OS
4043if [[ " ${HOST_OS} " == " mac" ]]; then
41- # Extract from macOS Keychain and pipe directly to VM
42- if ! security find-generic-password -s " Claude Code-credentials" -w 2> /dev/null | \
43- jq -c ' del(.claudeAiOauth.refreshToken)' | \
44- ssh " ${HOSTNAME} " ' cat > ~/.claude/.credentials.json' ; then
44+ # Try extracting from macOS Keychain with both possible service names
45+ if security find-generic-password -s " Claude Code-credentials" -w 2> /dev/null | \
46+ ssh " ${HOSTNAME} " ' cat > ~/.claude/.credentials.json' ; then
47+ echo " Found credentials under 'Claude Code-credentials'"
48+ elif security find-generic-password -s " Claude Code" -w 2> /dev/null | \
49+ ssh " ${HOSTNAME} " ' read key && jq --arg key "$key" ".primaryApiKey = \$key" ~/.claude.json > ~/.claude.json.tmp && mv ~/.claude.json.tmp ~/.claude.json' ; then
50+ echo " Found credentials under 'Claude Code'"
51+ else
4552 echo " Error: Could not find Claude Code credentials in macOS Keychain"
4653 echo " Please ensure you are logged in to Claude Code on the host"
4754 exit 1
4855 fi
56+
57+ # Set appropriate permissions
58+ ssh " ${HOSTNAME} " ' chmod 700 ~/.claude && chmod 600 ~/.claude/.credentials.json 2>/dev/null || chmod 600 ~/.claude.json'
4959elif [[ " ${HOST_OS} " == " linux" ]]; then
5060 # Copy directly from Linux filesystem
5161 if ! cat ~ /.claude/.credentials.json | \
@@ -55,12 +65,9 @@ elif [[ "${HOST_OS}" == "linux" ]]; then
5565 echo " Please ensure you are logged in to Claude Code on the host"
5666 exit 1
5767 fi
58- fi
5968
60- # Copy .claude.json configuration file
61- scp ~ /.claude.json " ${HOSTNAME} :~/.claude.json"
62-
63- # Set appropriate permissions
64- ssh " ${HOSTNAME} " ' chmod 700 ~/.claude && chmod 600 ~/.claude/.credentials.json'
69+ # Set appropriate permissions
70+ ssh " ${HOSTNAME} " ' chmod 700 ~/.claude && chmod 600 ~/.claude/.credentials.json'
71+ fi
6572
6673echo " Claude Code installed and configured in ${HOSTNAME} "
0 commit comments