@@ -36,16 +36,27 @@ 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+ jq -c ' del(.claudeAiOauth.refreshToken)' | \
47+ ssh " ${HOSTNAME} " ' cat > ~/.claude/.credentials.json' ; then
48+ echo " Found credentials under 'Claude Code-credentials'"
49+ elif security find-generic-password -s " Claude Code" -w 2> /dev/null | \
50+ ssh " ${HOSTNAME} " ' read key && jq --arg key "$key" ".primaryApiKey = \$key" ~/.claude.json > ~/.claude.json.tmp && mv ~/.claude.json.tmp ~/.claude.json' ; then
51+ echo " Found credentials under 'Claude Code'"
52+ else
4553 echo " Error: Could not find Claude Code credentials in macOS Keychain"
4654 echo " Please ensure you are logged in to Claude Code on the host"
4755 exit 1
4856 fi
57+
58+ # Set appropriate permissions
59+ ssh " ${HOSTNAME} " ' chmod 700 ~/.claude && chmod 600 ~/.claude/.credentials.json 2>/dev/null || chmod 600 ~/.claude.json'
4960elif [[ " ${HOST_OS} " == " linux" ]]; then
5061 # Copy directly from Linux filesystem
5162 if ! cat ~ /.claude/.credentials.json | \
@@ -55,12 +66,9 @@ elif [[ "${HOST_OS}" == "linux" ]]; then
5566 echo " Please ensure you are logged in to Claude Code on the host"
5667 exit 1
5768 fi
58- fi
5969
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'
70+ # Set appropriate permissions
71+ ssh " ${HOSTNAME} " ' chmod 700 ~/.claude && chmod 600 ~/.claude/.credentials.json'
72+ fi
6573
6674echo " Claude Code installed and configured in ${HOSTNAME} "
0 commit comments