Connect n8n to Claude Code (or other AI terminal tools) via SSH for powerful automation workflows.
Implemented from: NetworkChuck's n8n-claude-code-guide | Video: n8n + Claude Code is OVERPOWERED
Long workflows in Claude Code (or any LLM) can drift from context, hallucinate, and make fuzzy decisions. This solution utilizes N8N as a orchestration layer while still utilizing the powerful Claude Code environment. Massive credit to NetworkChuck for the implementation. His original README follows below, as are his support links.
What follows here is my implementation of his solution. My additions include:
- Added a Discord bot in place of Slack
- Containerized my WSL setup in Docker
- Added some example use cases
This is a Docker image containing two WSL instances: one runs Claude Code, one runs N8N. You add your credentials to the .env file and your are ready to run.
- Install Docker Desktop
- Configure
.envfile - Run
docker-compose up -d - Configure Discord bot
👉 Orchestration-Manual/DOCKER-LAUNCH-QUICKSTART.md
This is a step by step installation of the entire process, useful if you want to see how all the gears turn.
- Install WSL2 Ubuntu
- Install Node.js, Claude Code, n8n
- Configure SSH and Discord bot
- Set up workflows
👉 Orchestration-Manual/00-COMPLETE-SETUP-GUIDE.md
Not required for the orchestration.
- Discord Developer Portal Setup
- Install Discord Bot Script
- Import and Configure n8n Workflow
- Verify Everything is Running
- Test the Complete System
- Auto-Start Bot with System
👉 Orchestration-Manual/DISCORD-BOT-SETUP.md
As of the initial commit, most of these are untested. A brainstorm of potential use cases.
- basic-claude-test
- claude-with-sessions
- discord-webhook-simple
- system-health-monitor
- intelligent-issue-triage
- code-review-learning-system
- continuous-codebase-health-monitor
- multi-agent-code-development-pipeline
- multi-repo-dependency-update
- distributed-testing-deployment-pipeline
| I want to... | Go to... |
|---|---|
| Start with Docker | Orchestration-Manual/DOCKER-LAUNCH-QUICKSTART.md |
| Learn from scratch | Orchestration-Manual/00-COMPLETE-SETUP-GUIDE.md |
| Set up Discord bot | Orchestration-Manual/DISCORD-BOT-SETUP.md |
| Understand Docker vs WSL | Orchestration-Manual/CONTAINERIZATION-FAQ.md |
| Browse all docs | Orchestration-Manual/README.md |
All documentation is organized in the Orchestration-Manual/ folder:
Core Guides:
- 00-COMPLETE-SETUP-GUIDE.md - Complete A-Z setup (WSL-based, 2-3 hours)
- DOCKER-LAUNCH-QUICKSTART.md - One-command Docker launch (1 hour)
- DISCORD-BOT-SETUP.md - Detailed Discord bot configuration
- CONTAINERIZATION-FAQ.md - Docker vs WSL comparison
See Orchestration-Manual/README.md for complete documentation index
start-docker.bat/stop-docker.bat- Docker managementdocker-compose.yml- Complete containerized setupworkflows/- Pre-built n8n workflow templatesdiscord-bot-docker/- Discord bot for containers
- Prerequisites
- Architecture Overview
- Setup Guide
- Basic Usage
- Session Management
- Advanced Workflows
- Troubleshooting
- Resources
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
- Requires an Anthropic Pro subscription or API access
- Can be installed on any Linux-based machine (including Mac, Windows WSL)
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 |
┌─────────────┐ 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.
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- 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., 192.168.1.100 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"
First, test with a basic command:
hostnameIf that works, test Claude Code:
claude --versionYou should see the Claude Code version in the output.
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.
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.
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
The real power comes from maintaining conversations across multiple n8n executions.
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 }}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.
Create a workflow that lets you chat with Claude Code from your phone via Slack:
[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]
- 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"
@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
Common issues and solutions:
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
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
Make sure you're:
- Using the exact same session ID
- Including the
-rflag when resuming - Not letting too much time pass (sessions may expire)
Slack has a 4000 character limit. Add to your prompts:
Keep response under 2000 characters.
For long-running Claude operations:
- Increase SSH timeout in n8n node settings
- Consider breaking complex tasks into smaller prompts
- 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
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!