Opencode - TyRoden/opencode-remote-ssh - подключить плагин ssh
Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2026
Opencode - TyRoden/opencode-remote-ssh - подключить плагин ssh
Установка зависимостей на mac os:
Node.js — нужен для сборки плагина Go 1.21+ — нужен для сборки stub
Установка через brew:
brew install node brew install go
Проверка версий:
% node --version v26.0.0 % npm --version 11.12.1 % go version go version go1.26.4 darwin/arm64
Далее склонировать и собрать репозиторий:
501 — это UID пользователя (antonmac), а 20 — GID группы staff. Это числовые эквиваленты antonmac:staff. git clone https://github.com/TyRoden/opencode-remote-ssh.git ~/opencode-remote-ssh sudo chown -R 501:20 "/Users/antonmac/.npm" rm -rf ~/opencode-remote-ssh/plugin/node_modules cd ~/opencode-remote-ssh/plugin && npm install && npm run build СОБРАТЬ stub СТРОГО под Linux: cd ~/opencode-remote-ssh/stub && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o bin/opencode-remote-stub ./cmd
Конфиг:
# vi ~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
[
"/Users/antonmac/opencode-remote-ssh/plugin",
{
"providers": {
"default": {
"strategy": "first_available",
"hosts": [
{
"name": "my-server",
"ssh": {
"host": "XX.XX.XX.XX",
"user": "root",
"port": 22,
"identityFile": "~/.ssh/id_ed25519"
},
"labels": ["linux"]
}
]
}
}
}
]
]
}
Загрузить stub на удалённый сервер
% cd ~/opencode-remote-ssh/scripts % sudo chown -R antonmac:staff ~/.ssh % ssh-keygen -t ed25519 -C "opencode-remote" -f ~/.ssh/id_ed25519 % ssh-copy-id -i ~/.ssh/id_ed25519.pub root@XX.XX.XX.XX && cd ~/opencode-remote-ssh/scripts && ./setup-host.sh XX.XX.XX.XX root 22 ~/.ssh/id_ed25519 % scp -i ~/.ssh/id_ed25519 ~/opencode-remote-ssh/stub/bin/opencode-remote-stub root@XX.XX.XX.XX:/root/.opencode-remote/bin/
% scp -i ~/.ssh/id_ed25519 ~/opencode-remote-ssh/stub/bin/opencode-remote-stub root@XX.XX.XX.XX:/root/.opencode-remote/bin/
% ssh -i ~/.ssh/id_ed25519 root@XX.XX.XX.XX "python3 -c \"
import os, subprocess, time
null_in = open('/dev/null', 'rb')
null_out = open('/dev/null', 'ab')
cmd = ['/root/.opencode-remote/bin/opencode-remote-stub',
'--listen', '127.0.0.1:39217',
'--token-file', '/root/.opencode-remote/run/stub.token',
'--state-dir', '/root/.opencode-remote/state',
'--log-file', '/root/.opencode-remote/log/stub.log']
proc = subprocess.Popen(cmd, stdin=null_in, stdout=null_out, stderr=null_out, close_fds=True, preexec_fn=os.setsid)
time.sleep(2)
print('OK' if proc.poll() is None else 'FAILED')
\""
OK
Проверить на сервере:
netstat -nlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:39217 0.0.0.0:* LISTEN 2425/opencode-remot
Проект:
https://github.com/TyRoden/opencode-remote-ssh
