theNetworkChuck/n8n-claude-code-guide
概要
Connect n8n to Claude Code via SSH for powerful automation workflows
開発ツール計測したスター増加
- 24時間
- 0
- 7日間
- -1
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルn8n + Claude Code Integration Guide
Connect n8n to Claude Code (or other AI terminal tools) via SSH for powerful automation workflows.
Video: n8n + Claude Code is OVERPOWERED
Table of Contents
- Prerequisites
- Architecture Overview
- Setup Guide
- Basic Usage
- Session Management
- Advanced Workflows
- Troubleshooting
- Resources
Prerequisites
You'll need three things:
- n8n Instance - Self-hosted or cloud
- AI Terminal Tool - Claude Code (recommended), Gemini CLI, or Codex
- Coffee - That's just the rules
Claude Code Requirements
- Requires an Anthropic Pro subscription or API access
- Can be installed on any Linux-based machine (including Mac, Windows WSL)
Where to Install Claude Code
You can install Claude Code on:
| Location | Pros | Cons |
|---|---|---|
| Same VPS as n8n | Simple setup, same machine | Resource sharing |
| Dedicated Ubuntu server | Best performance, local file access | Additional infrastructure |
| Raspberry Pi | Low cost, always on | Limited resources |
| Hostinger VPS | Cloud-based, easy setup | Monthly cost |
Architecture Overview
┌─────────────┐ SSH ┌──────────────────┐
│ n8n │ ───────────────────► │ Linux Server │
│ (workflow) │ │ (Claude Code) │
└─────────────┘ └──────────────────┘
│
▼
┌──────────────────┐
│ Your Files │
│ Your Skills │
│ Your Context │
└──────────────────┘
The magic? SSH. That's it. n8n uses the SSH node to remotely execute Claude Code commands on your server.
Setup Guide
1. Install Claude Code
On your Linux server (Ubuntu example):
# Install Node.js (if not installed)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install Claude Code globally
npm install -g @anthropic-ai/claude-code
# Verify installation
claude --version
# Authenticate (follow prompts)
claude auth
2. Configure n8n SSH Credentials
- In n8n, add an SSH node to your workflow
- Click Create New Credential
- Fill in your server details:
| Field | Value |
|---|---|
| Host | Your server IP (e.g., 10.77.14.30 or public IP) |
| Port | 22 (default SSH) |
| Username | Your SSH username |
| Authentication | Password or Private Key |
| Password/Key | Your credentials |
- Click Save - Look for "Connection tested successfully"
3. Test the Connection
First, test with a basic command:
hostname
If that works, test Claude Code:
claude --version
You should see the Claude Code version in the output.
Basic Usage
Simple Claude Command
Use the -p (print) flag for headless mode - send a prompt and get a response:
SSH Node Command:
claude -p "Why do pugs look so weird?"
The -p flag puts Claude in "print mode" - it processes your prompt and returns the result without interactive input.
Adding Context (Working Directory)
Give Claude access to your project files by changing directory first:
SSH Node Command:
cd /path/to/your/project && claude -p "Is this video going to be any good?"
Claude will read files in that directory to inform its response. This is the power - context from your local files.
Using Skills and Agents
Put Claude in "dangerous mode" to enable tool use and agent deployment:
SSH Node Command:
claude --dangerously-skip-permissions -p "Use your unifi skill to check wifi status, network performance, and security. Deploy three agents, one for each task. Keep response under 2000 characters."
This enables Claude to:
- Use installed skills (like UniFi, Slack, etc.)
- Deploy multiple agents in parallel
- Execute code and scripts
- Access APIs and external services
Session Management
The real power comes from maintaining conversations across multiple n8n executions.
Creating a Session ID
Add a Code node before your SSH node to generate a UUID:
Code Node (JavaScript):
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0;
const v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
return [{ json: { sessionId: uuid } }];
SSH Node Command:
claude -p "How many access points are up right now?" --session-id {{ $json.sessionId }}
Resuming Sessions
To continue a conversation, use the -r (resume) flag with the same session ID:
SSH Node Command (Follow-up):
claude -r --session-id {{ $('Code').item.json.sessionId }} -p "Why is one of them down?"
The -r flag resumes the previous session, so Claude remembers the context of your earlier questions.
Advanced Workflows
Slack Integration (Mobile Access)
Create a workflow that lets you chat with Claude Code from your phone via Slack:
Workflow Structure:
[Slack Trigger] → [Code: Generate UUID] → [SSH: Initial Claude Command]
↓
[Slack: Send Response]
↓
[Slack: Ask Continue?]
↓
[If Node]
/ \
[False] [True]
↓ ↓
[Loop: SSH Resume] [End Workflow]
↓
[Slack: Response]
↓
[Back to Ask Continue]
Key Components:
- Slack Trigger: Listens for messages mentioning your bot
- Code Node: Generates session UUID (see above)
- SSH Node (Initial): First Claude command with
--session-id - Slack Response: Posts Claude's response back to channel
- Slack Dropdown: "Are you done? [Yes] [No]"
- If Node: Routes based on user selection
- SSH Node (Resume): Uses
-r --session-idfor follow-ups - Loop: Continues until user selects "Yes"
Example Prompts from Slack:
@bot deploy two agents to battle it out: which is better, nano or neovim?
Research, contrast, compare, give me a solid answer. Keep response under 2000 characters.
@bot use your NAS skill to check how my stuff server is doing
Troubleshooting
Common issues and solutions:
Claude Command Not Found
The SSH session may not load your shell profile. Solutions:
Use full path:
/usr/local/bin/claude -p "your prompt"Source profile first:
source ~/.bashrc && claude -p "your prompt"Add to system PATH:
sudo ln -s $(which claude) /usr/local/bin/claude
Permission Denied Errors
If Claude can't access files or run tools:
- Ensure the SSH user has proper permissions
- Use
--dangerously-skip-permissionsfor tool access - Check file ownership in your project directories
Session Not Resuming
Make sure you're:
- Using the exact same session ID
- Including the
-rflag when resuming - Not letting too much time pass (sessions may expire)
Response Too Long
Slack has a 4000 character limit. Add to your prompts:
Keep response under 2000 characters.
SSH Connection Timeout
For long-running Claude operations:
- Increase SSH timeout in n8n node settings
- Consider breaking complex tasks into smaller prompts
Resources
- NetworkChuck Academy: n8n Course | Claude Code Course
- Claude Code Docs: Official Documentation
- n8n Docs: SSH Node
- Previous Videos:
- n8n Part 1 - Getting Started with n8n
- n8n Part 2 - n8n Now Runs My ENTIRE Homelab (Terry)
- AI in the Terminal - Claude Code, Gemini CLI, Codex Introduction
What's Next?
In the next video, we're building a full IT Department with:
- n8n as the orchestrator
- Claude Code, Gemini CLI, and Codex as the workers
- Automated monitoring, alerting, and remediation
Subscribe to catch it when it drops!
関連プロジェクトを探す
読み込み中…