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; + } } }