From 2073ab1ec808bc834f505b7657d7442828f85ab7 Mon Sep 17 00:00:00 2001 From: kim Date: Sat, 31 Oct 2026 11:16:20 +0900 Subject: [PATCH] =?UTF-8?q?anthropic=20testConnection:=20=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=20=EC=8B=9C=20=EC=98=88=EC=99=B8=20=EB=8C=80=EC=8B=A0?= =?UTF-8?q?=20false=20=E2=80=94=20=EC=9D=BC=EC=8B=9C=20=EB=84=A4=ED=8A=B8?= =?UTF-8?q?=EC=9B=8C=ED=81=AC=20=EB=81=8A=EA=B9=80=EC=9D=B4=20/api/status?= =?UTF-8?q?=20500=EC=9D=B4=20=EB=90=98=EB=8D=98=20=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 다른 어댑터(ollama, openai-compat)처럼 false를 돌려준다. z840용 설정 스크립트 추가: setup-sshd-2984.sh(SSH 서버, 포트 2984, 공개키 전용), setup-tailscale.sh(공식 저장소 설치). Co-Authored-By: Claude Sonnet 5.5 --- scripts/setup-sshd-2984.sh | 53 ++++++++++++++++++++++++++++++ scripts/setup-tailscale.sh | 21 ++++++++++++ src/providers/anthropic-adapter.ts | 16 +++++---- 3 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 scripts/setup-sshd-2984.sh create mode 100644 scripts/setup-tailscale.sh diff --git a/scripts/setup-sshd-2984.sh b/scripts/setup-sshd-2984.sh new file mode 100644 index 0000000..e08e4a2 --- /dev/null +++ b/scripts/setup-sshd-2984.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# 이 박스(z840)에 SSH 서버를 설치하고 2984번 포트, 공개키 로그인만 허용하도록 설정한다. +# 루트로: sudo bash /srv/homeclaw/scripts/setup-sshd-2984.sh (여러 번 실행해도 안전) +# 이사한 z840에는 openssh-server가 없었다(2026-10-31 확인, 클라이언트만 설치됨). +# 접속할 기기의 공개키를 /home/kim/.ssh/authorized_keys에 넣은 뒤 다시 실행하면 비밀번호 로그인이 꺼진다. +# authorized_keys가 비어 있을 때 비밀번호를 끄면 아무도 못 들어오므로, 키가 있을 때만 끈다. +set -e +[ "$(id -u)" = 0 ] || { echo "루트로 실행하세요 (sudo)"; exit 1; } + +PORT=2984 +USER_NAME=kim +KEYS=/home/$USER_NAME/.ssh/authorized_keys +CONF=/etc/ssh/sshd_config.d/10-homeclaw.conf + +if ! dpkg -s openssh-server >/dev/null 2>&1; then + apt-get install -y openssh-server +fi + +# 키가 한 줄이라도 있으면(주석·빈 줄 제외) 비밀번호 로그인을 끈다 +if [ -s "$KEYS" ] && grep -qvE '^\s*(#|$)' "$KEYS"; then + PASSWORD=no +else + PASSWORD=yes +fi + +mkdir -p /etc/ssh/sshd_config.d +cat > "$CONF" </dev/null || true +systemctl enable ssh.service +systemctl restart ssh.service + +echo "== 결과" +ss -ltnp | grep -E ":$PORT\b" || { echo "$PORT 포트에서 듣지 않는다 — journalctl -u ssh 확인"; exit 1; } +sshd -T | grep -E '^(port|passwordauthentication|pubkeyauthentication|permitrootlogin|allowusers) ' +if [ "$PASSWORD" = yes ]; then + echo + echo "주의: $KEYS 에 키가 없어 비밀번호 로그인을 아직 끄지 않았다." + echo "접속할 기기의 공개키(한 줄)를 그 파일에 추가한 뒤 이 스크립트를 다시 실행하면 비밀번호 로그인이 꺼진다." +fi +echo "접속: ssh -p $PORT $USER_NAME@192.168.0.5" diff --git a/scripts/setup-tailscale.sh b/scripts/setup-tailscale.sh new file mode 100644 index 0000000..60afa2a --- /dev/null +++ b/scripts/setup-tailscale.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# 공식 저장소(pkgs.tailscale.com)에서 Tailscale을 설치하고 서비스를 켠다. +# 루트로: sudo bash /srv/homeclaw/scripts/setup-tailscale.sh (여러 번 실행해도 안전) +# 설치 뒤 로그인은 `sudo tailscale up`이 출력하는 주소를 브라우저로 열어 계정으로 승인한다(이 스크립트는 로그인하지 않는다). +set -e +[ "$(id -u)" = 0 ] || { echo "루트로 실행하세요 (sudo)"; exit 1; } +. /etc/os-release + +if ! dpkg -s tailscale >/dev/null 2>&1; then + install -d -m 0755 /usr/share/keyrings + curl -fsSL "https://pkgs.tailscale.com/stable/ubuntu/$VERSION_CODENAME.noarmor.gpg" -o /usr/share/keyrings/tailscale-archive-keyring.gpg + curl -fsSL "https://pkgs.tailscale.com/stable/ubuntu/$VERSION_CODENAME.tailscale-keyring.list" -o /etc/apt/sources.list.d/tailscale.list + apt-get update + apt-get install -y tailscale +fi + +systemctl enable --now tailscaled +echo "== 결과" +tailscale version | head -1 +systemctl is-active tailscaled +tailscale status 2>&1 | head -3 diff --git a/src/providers/anthropic-adapter.ts b/src/providers/anthropic-adapter.ts index 427ac2f..a720975 100644 --- a/src/providers/anthropic-adapter.ts +++ b/src/providers/anthropic-adapter.ts @@ -125,12 +125,16 @@ export class AnthropicAdapter implements LLMProvider { } async testConnection(): Promise { - await this.post('/v1/messages', { - model: 'claude-haiku-5-5', - max_tokens: 1, - messages: [{ role: 'user', content: 'hi' }], - }); - return true; + try { + await this.post('/v1/messages', { + model: 'claude-haiku-5-5', + max_tokens: 1, + messages: [{ role: 'user', content: 'hi' }], + }); + return true; + } catch { + return false; + } } }