1. Requirements

  • OS: CentOS 7 / 8 / Stream 9
  • Node.js: v18 or higher
  • RAM: 2 GB or more recommended
  • Network: Access to the Anthropic API

2. Install Node.js

1
2
3
4
5
6
7
8
9
# Add the NodeSource repository
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -

# Install Node.js
sudo yum install -y nodejs

# Verify
node -v
npm -v

If the Node.js version is too old, use nvm to manage versions:

1
2
3
4
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20

3. Install Claude Code

1
2
3
4
5
# Global install
npm install -g @anthropic-ai/claude-code

# Verify
claude --version

Two ways to fix permission issues:

1
2
3
4
5
6
7
8
# Option 1: sudo
sudo npm install -g @anthropic-ai/claude-code

# Option 2: change the npm global prefix (recommended)
mkdir -p ~/.npm-global
npm config set prefix "~/.npm-global"
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

4. Configure the API Key

1
2
3
4
5
6
# Option 1: environment variable (recommended)
echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.bashrc
source ~/.bashrc

# Verify
echo $ANTHROPIC_API_KEY

Option 2: just run claude — it will prompt you for the API key on first launch.

5. Basic Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Start an interactive session
cd /path/to/your/project
claude

# Ask a question directly (non-interactive)
claude -p "Write a Python script that counts the number of files in the current directory"

# Analyze code
cat main.py | claude -p "Analyze potential issues in this code"

# View or edit configuration
claude config

# Update to the latest version
claude update
Command Description
claude Start an interactive session
claude -p "question" Ask directly in non-interactive mode
claude config View or edit configuration
claude update Update to the latest version

6. Network Troubleshooting

If connecting to the Anthropic API times out:

1
2
3
4
5
6
# Configure a proxy
export https_proxy="http://your-proxy:port"
export http_proxy="http://your-proxy:port"

# Test connectivity
curl -s https://api.anthropic.com/ | head -5

7. Security Tips

1
2
3
4
5
6
7
8
9
# Never hard-code the API key — always use an environment variable
echo 'export ANTHROPIC_API_KEY="sk-ant-xxx"' >> ~/.bashrc  # ✅
# ANTHROPIC_API_KEY=sk-ant-xxx written in code  # ❌

# Restrict file permissions
chmod 600 ~/.bashrc

# Check for leaks
grep -r "ANTHROPIC_API_KEY" --include="*.py" --include="*.js" .