headscale-tailscale-replace.../CLIENT_SETUP_GUIDE.md
시골약사 53c1f45e02 🚀 Add complete client registration system for FARMQ Headscale
## New Features:
- **register-client.sh**: Automated client registration script
  - Auto-detects OS (Ubuntu/CentOS/macOS)
  - Installs Tailscale automatically
  - Registers to https://head.0bin.in with pre-auth key
  - Verifies connection and displays status

- **create-preauth-key.sh**: Pre-auth key management script
  - Creates users and pre-auth keys with custom expiration
  - Supports reusable keys for multiple devices
  - Provides ready-to-use registration commands
  - Example: `./create-preauth-key.sh pharmacy1 7d`

- **CLIENT_SETUP_GUIDE.md**: Complete installation guide
  - Automated and manual installation instructions
  - Cross-platform support (Linux/macOS/Windows/Mobile)
  - Troubleshooting section
  - Key management for admins

## Pharmacy Page Fix:
- Fix machine count display in pharmacy management page
- Update get_all_pharmacies_with_stats() to use actual Headscale Node data
- Show correct online/offline machine counts per pharmacy
- Fixed: "0대" → "2대 online" for proper machine statistics

## Key Benefits:
- **One-line registration**: `sudo ./register-client.sh`
- **Pre-auth keys work once, connect forever** - answers user's question
- **Reusable keys** for multiple devices per pharmacy
- **Cross-platform** support for all major operating systems

Current active keys:
- myuser: fc4f2dc55ee00c5352823d156129b9ce2df4db02f1d76a21
- pharmacy1: 5c15b41ea8b135dbed42455ad1a9a0cf0352b100defd241c (7d validity)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 18:23:04 +09:00

194 lines
4.6 KiB
Markdown

# 팜큐(FARMQ) Headscale 클라이언트 설치 가이드
## 🏥 개요
팜큐 네트워크에 PC를 연결하기 위한 간편한 설치 가이드입니다.
## 📋 Pre-auth Key 정보
### ✅ Pre-auth Key 특징:
- **1회 등록**: 한 번 사용하면 해당 머신이 영구적으로 네트워크에 등록됩니다
- **자동 재연결**: 재부팅 후에도 자동으로 연결됩니다
- **재사용 가능**: 동일한 key로 여러 머신을 등록할 수 있습니다 (설정에 따라)
### 🔑 현재 유효한 Key:
- **myuser**: `fc4f2dc55ee00c5352823d156129b9ce2df4db02f1d76a21` (재사용 가능)
- **pharmacy1**: `5c15b41ea8b135dbed42455ad1a9a0cf0352b100defd241c` (7일 유효, 재사용 가능)
## 🚀 자동 설치 (권장)
### Linux/Ubuntu 시스템
1. **스크립트 다운로드**:
```bash
wget https://head.0bin.in/register-client.sh
chmod +x register-client.sh
```
2. **스크립트 실행**:
```bash
sudo ./register-client.sh
```
### 수동으로 Pre-auth Key 업데이트
스크립트의 Pre-auth Key를 업데이트하려면:
```bash
# 스크립트 편집
nano register-client.sh
# PREAUTH_KEY 값을 새로운 key로 변경
PREAUTH_KEY="새로운키값"
```
## 🔧 수동 설치
### 1. Tailscale 설치
#### Ubuntu/Debian:
```bash
curl -fsSL https://tailscale.com/install.sh | sh
```
#### CentOS/RHEL:
```bash
curl -fsSL https://tailscale.com/install.sh | sh
```
#### macOS:
```bash
# Homebrew 사용
brew install --cask tailscale
# 또는 직접 다운로드
# https://tailscale.com/download/mac
```
#### Windows:
1. https://tailscale.com/download/windows 에서 다운로드
2. 설치 후 아래 명령어를 관리자 권한 PowerShell에서 실행
### 2. Headscale 서버에 등록
#### Linux/macOS:
```bash
sudo tailscale up \
--login-server="https://head.0bin.in" \
--authkey="fc4f2dc55ee00c5352823d156129b9ce2df4db02f1d76a21" \
--accept-routes \
--accept-dns=false
```
#### Windows (PowerShell 관리자 권한):
```powershell
tailscale up `
--login-server="https://head.0bin.in" `
--authkey="fc4f2dc55ee00c5352823d156129b9ce2df4db02f1d76a21" `
--accept-routes `
--accept-dns=false
```
## 📊 연결 확인
### 연결 상태 확인:
```bash
tailscale status
```
### IP 주소 확인:
```bash
tailscale ip -4
```
### 네트워크 테스트:
```bash
# 다른 팜큐 머신으로 핑 테스트
ping 100.64.0.1
```
## 🔑 관리자용 - Pre-auth Key 생성
### 새로운 약국용 Key 생성:
1. **스크립트 사용** (권장):
```bash
./create-preauth-key.sh pharmacy2 30d
```
2. **수동 생성**:
```bash
# 사용자 생성 (필요시)
docker exec headscale headscale users create pharmacy2
# Pre-auth key 생성
docker exec headscale headscale preauthkeys create \
-u 2 --expiration 30d --reusable
```
### Key 관리 명령어:
```bash
# 사용자 목록 확인
docker exec headscale headscale users list
# Pre-auth key 목록 확인 (사용자 ID 필요)
docker exec headscale headscale preauthkeys list -u 1
# 만료된 key 삭제
docker exec headscale headscale preauthkeys expire -k <key_id>
```
## 🛠️ 문제해결
### 연결 안됨:
1. **방화벽 확인**: 8080, 443 포트가 열려있는지 확인
2. **DNS 확인**: `https://head.0bin.in` 접근 가능한지 확인
3. **Key 유효성**: Pre-auth key가 만료되지 않았는지 확인
### 기존 연결 해제:
```bash
sudo tailscale logout
```
### 완전 재설정:
```bash
sudo tailscale logout
sudo tailscale up --login-server="https://head.0bin.in" --authkey="새로운키"
```
## 📱 모바일 설정
### Android/iOS:
1. Tailscale 앱 설치
2. "Use a different server" 선택
3. 서버 URL: `https://head.0bin.in`
4. Pre-auth key 입력 (위 key 중 하나 사용)
## 🔐 보안 참고사항
- Pre-auth key는 민감한 정보입니다. 공유 시 주의하세요
- Key가 만료되기 전에 새로운 key를 생성하세요
- 불필요한 key는 정기적으로 만료시키세요
- 각 약국별로 별도의 사용자와 key를 사용하는 것을 권장합니다
## 📞 지원
문제가 발생하면 다음 정보를 포함하여 문의하세요:
- 운영체제 정보
- `tailscale status` 출력
- 에러 메시지
- 사용한 Pre-auth key (마지막 8자리만)
---
## 📋 요약
1. **간편 설치**: `register-client.sh` 스크립트 실행
2. **수동 설치**: Tailscale 설치 → `tailscale up` 명령어 실행
3. **연결 확인**: `tailscale status``tailscale ip` 확인
4. **문제 시**: 재부팅 또는 logout 후 재연결
**서버**: https://head.0bin.in
**기본 Key**: `fc4f2dc55ee00c5352823d156129b9ce2df4db02f1d76a21`