Skip to main content

SSH MCP server for remote Linux command execution via Model Context Protocol

Project description

SSH MCP Server

SSH üzerinden uzak Linux sunucularında komut çalıştırma ve sistem yönetimi için Claude Desktop MCP Server'ı.

🚀 Özellikler

🛠️ Araçlar (Tools)

  • execute_command: Shell komutları çalıştırma
  • file_operations: Dosya okuma/yazma/listeleme
  • system_monitor: Sistem kaynaklarını izleme
  • process_manager: Process yönetimi
  • sftp_download: SFTP ile dosya indirme (text/base64)
  • sftp_upload: SFTP ile dosya yükleme (overwrite/append)

📊 Kaynaklar (Resources)

  • ssh://system: Sistem bilgileri
  • ssh://processes: Çalışan processler
  • ssh://disk: Disk kullanımı
  • ssh://network: Ağ bilgileri
  • ssh://logs: Sistem logları

🔒 Güvenlik

  • Tehlikeli komutlar otomatik engellenir
  • SSH key authentication desteği
  • Timeout koruması
  • Safe file operations (SFTP)
  • Process kill sadece numeric PID ile
  • Tüm işlemler loglanır

📦 Installation / Kurulum

Option 1: Using uvx (Recommended / Önerilen)

No installation required! Just configure Claude Desktop:

{
  "mcpServers": {
    "ssh": {
      "command": "uvx",
      "args": ["mcp-server-ssh"],
      "env": {
        "SSH_HOST": "your_server_ip",
        "SSH_PORT": "22",
        "SSH_USER": "your_username",
        "SSH_PASSWORD": "your_password",
        "SSH_KEY_FILE": "/path/to/private_key"
      }
    }
  }
}

Option 2: Install from PyPI

pip install mcp-server-ssh

Option 3: Install from Source / Kaynak Koddan Kurulum

cd ssh-mcp-server
pip install -e .
# or
./install.sh

Environment Variables

.env dosyasını düzenleyin:

SSH_HOST=your_server_ip
SSH_PORT=22
SSH_USER=your_username
SSH_PASSWORD=your_password
SSH_TIMEOUT=30

# SSH Key Authentication (optional - preferred over password)
SSH_KEY_FILE=/path/to/your/private_key
SSH_KEY_PASSPHRASE=your_key_passphrase  # Optional: only if key is encrypted

Authentication Priority:

  1. SSH_KEY_FILE set ise -> Key authentication
  2. SSH_PASSWORD set ise -> Password authentication
  3. Hicbiri yoksa -> Default key lookup (~/.ssh/id_rsa) + SSH agent

Test

python test_ssh.py

🔧 Claude Desktop Configuration

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "ssh-mcp-server": {
      "command": "/path/to/ssh-mcp-server/venv/bin/python",
      "args": ["/path/to/ssh-mcp-server/server.py"],
      "cwd": "/path/to/ssh-mcp-server"
    }
  }
}

🧪 Kullanım Örnekleri

Sistem Bilgileri

"Linux sunucumda sistem bilgilerini göster"
"Sunucunun uptime'ını kontrol et"
"Disk kullanımını göster"

Dosya İşlemleri

"/etc/hosts dosyasını oku"
"/var/log/nginx/error.log dosyasının son 100 satırını göster"
"/home dizinini listele"

Process Yönetimi

"Nginx processlerini listele"
"Python processlerini bul"
"CPU kullanımını göster"

Komut Çalıştırma

"df -h komutunu çalıştır"
"ps aux | grep nginx"
"systemctl status docker"

🔐 Güvenlik Özellikleri

Engellenen Komutlar

  • rm -rf /
  • format, mkfs
  • dd if=/dev/zero of=/dev/sda
  • Fork bomb patterns
  • shutdown, reboot, halt
  • User deletion commands

Güvenlik Best Practices

  1. Sadece güvendiğiniz sunucularda kullanın
  2. Limited yetkili kullanıcı hesabı kullanın
  3. SSH key authentication tercih edin
  4. Logları düzenli kontrol edin
  5. Firewall kurallarını gözden geçirin

📋 Mevcut Araçlar

execute_command

{
  "command": "ls -la /home",
  "timeout": 30
}

file_operations

{
  "operation": "read",
  "path": "/etc/hosts",
  "limit": 100
}

system_monitor

{
  "metric": "all",
  "detailed": true
}

process_manager

{
  "action": "search",
  "target": "nginx"
}

sftp_download

{
  "remote_path": "/etc/hosts",
  "encoding": "utf-8"
}

sftp_upload

{
  "remote_path": "/tmp/test.txt",
  "content": "Hello World",
  "mode": "overwrite"
}

🐛 Sorun Giderme

SSH Bağlantısı Başarısız

# Test SSH bağlantısı
ssh -p 42922 root@31.210.36.85

# .env dosyasını kontrol edin
cat .env

# SSH client test
python test_ssh.py

MCP Server Başlamıyor

# Virtual environment kontrol
source venv/bin/activate
python -c "import paramiko; print('OK')"

# Server test
python server.py

Komutlar Çalışmıyor

  1. SSH kullanıcısının yetkileri
  2. Komutun path'te olması
  3. Timeout değeri
  4. Güvenlik kısıtlamaları

📊 Performans

Optimizasyon

  • Connection pooling (gelecek sürüm)
  • Command caching
  • Parallel execution
  • Resource monitoring

Limits

  • Command timeout: 30s (varsayılan)
  • File read limit: 100 lines (varsayılan)
  • Connection timeout: 30s
  • Memory usage monitoring

🔄 Güncellemeler

v1.0.0

  • Temel SSH komut çalıştırma
  • Dosya operasyonları
  • Sistem monitoring
  • Process management
  • Güvenlik kontrolleri

Roadmap

  • Connection pooling
  • Interactive shell
  • Multi-server support

📊 Activity Dashboard

SSH MCP server aktivitelerini izlemek için modern web dashboard:

Dashboard Özellikleri

  • 📈 Real-time aktivite izleme
  • 📊 İstatistik ve grafikler
  • 🔍 Detaylı arama ve filtreleme
  • 📥 Export (JSON/CSV)
  • 🎨 Modern responsive tasarım

Dashboard Başlatma

cd ssh-mcp-server
./start_dashboard.sh

Dashboard http://localhost:5555 adresinde açılacaktır.

⚠️ Production Uyarısı: Development sunucusu sadece test için uygundur. Production ortamında güvenlik ve performans için profesyonel web sunucusu kullanın:

# Gunicorn ile production deployment
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5555 ssh_log_dashboard:app

# Nginx reverse proxy önerisi
# nginx.conf:
# location /ssh-dashboard/ {
#     proxy_pass http://127.0.0.1:5555/;
#     proxy_set_header Host $host;
#     proxy_set_header X-Real-IP $remote_addr;
# }

Dashboard Sayfaları

  1. Overview: Genel istatistikler ve timeline
  2. Activities: Tüm aktivitelerin detaylı listesi
  3. Sessions: SSH oturumları ve analizleri
  4. Commands: En çok kullanılan komutlar
  5. Errors: Hata analizi ve raporları
  6. Search: Gelişmiş arama özellikleri

📞 Destek

Loglar

tail -f ~/.local/share/Claude/logs/mcp-server-ssh.log

Debug Mode

DEBUG=1 python server.py

Common Issues

  1. Connection refused: Firewall/port kontrol
  2. Authentication failed: Username/password kontrol
  3. Command not found: PATH ve package kurulumu
  4. Permission denied: User permissions kontrol

⚖️ License

MIT License

🤝 Contributing

  1. Fork repository
  2. Create feature branch
  3. Test thoroughly
  4. Submit pull request

⚠️ Disclaimer

Bu tool sistem yönetimi içindir. Kötü amaçlı kullanımdan kullanıcı sorumludur. Production sistemlerde dikkatli kullanın.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_ssh-1.0.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_ssh-1.0.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_ssh-1.0.0.tar.gz.

File metadata

  • Download URL: mcp_server_ssh-1.0.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for mcp_server_ssh-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9cf79662710fef83bd132549a70aef3ab3281d93126c4ee0258033bb6b94a6e9
MD5 b2047ddfcbe46119225d65116b220713
BLAKE2b-256 659d2012fb3a3324ab9734700a850120dee78729417ad791d40b0fad717b2b07

See more details on using hashes here.

File details

Details for the file mcp_server_ssh-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_server_ssh-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for mcp_server_ssh-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1d59735f8b582899e2d8b6b1d8db83b2bf59e3fb3c6947bdfac7920eb5b7c64
MD5 3868ed7830ef6d11e58da51eff84cd60
BLAKE2b-256 679f73a5a1f024f4cedf92068faa6e1c3084c9ab82ec72f12d82144e431df845

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page