Site icon 지락문화예술공작단

[OpenClaw] OpenClaw + Google gemini + Telegram 연동

설치 준비


계정생성
useradd donald
su - donald
EACCESS 권한 오류를 피하기 위한 환경 설정
sudo 권한 없이 전역 패키지 설치(-g 옵션)가 필요한 경우
cd ~
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
굳이 필요가 없다는 생각
경로 구성
cd ~
mkdir openclaw
cd openclaw
npm init -y

설치


1. OpenClaw 설치 (LLM 없이)
로컬 LLM빌드를 거치지 않고 API모드를 위한 가벼운 설치
1. 1 로컬 설치 (추천)
NODE_LLAMA_CPP_SKIP_DOWNLOAD=true npm install openclaw@latest
1.2 전역 설치
NODE_LLAMA_CPP_SKIP_DOWNLOAD=true npm install -g openclaw@latest
2. openclaw 설치 방식에 따른 명령어 차이점
2.1 로컬 설치시
npx openclaw doctor
openclaw 실행을 위하여 npx 명령어 필요
2.2 전역 설치시
openclaw doctor
openclaw 명령어가 리눅스 시스템 자체에 (/usr/ 와 같은 위치) 설치되므로 바로 어디서나 실행 가능
3. 명령어 실행 시 참고
openclaw 명령을 실행 하는 경우
cd ~/openclaw
를 통해 openclaw “디렉토리 내부(하단)”에서 수행
만약 openclaw 디렉토리 외부에서 수행하게 되면
“openclaw” 가 없다고 판단 후, 임시 다운로드를 받게 되고
.nmp/_npx 디렉토리에 계속해서 쌓이게 됨
4. 업데이트 관련
설치후 나오는 메세지 중

added 665 packages, and audited 666 packages in 49s

124 packages are looking for funding
run `npm fund` for details

25 high severity vulnerabilities

To address issues that do not require attention, run:
npm audit fix

To address all issues (including breaking changes), run:
npm audit fix –force

Run `npm audit` for details.
$ npm audit fix

added 5 packages, and audited 671 packages in 4s

127 packages are looking for funding
run `npm fund` for details

“npm audit” 에 대한 명령어 안내가 출력 됨
4.1 npm audit fix
4.2 npm audit fix –force
해당 출력 내용은 “필수” 성격은 아니므로
가볍게 “npm audit fix” 한번 정도 실행 (건너 뛰어도 무방함)

설정 by onboard


마법사 형태의 질/답을 통하여 설정파일 생성
npx openclaw onboard
모든 작업 완료 후
npx openclaw onbaord --install-daemon
백그라운드 서비스 등록
다만, root아닌 일반 계정으로 등록시 권한이 없으므로 기대한 결과가 나오지 않음
추후 별도의 방법 (PM2 활용 등)을 통하여 서비스(daemon) 화 필요하므로
“npx openclaw onboard” 만으로 진행하면 됨

onboard 절차


I understand this is powerful and inherently risky. Continue?
=> Yes
Onboarding mode
=> QuickStart
Model/auth provider
=> Google
(이 글에서는 구글 제미나이를 사용)
Enter Gemini API key
=> AXXXXXXXXXXXXXXXXXXXXXXXXXXXX (임의 입력값)
https://aistudio.google.com/
Google AI Studio → Get API key → 생성된 API키 값을 복사하여 입력
Default model
=> google/gemini-2.5-flash
Select channel
=> Telegram (Bot API)
(이 글에서는 텔레그램 사용)
Enter Telegram bot token
=> 1234554321:AXXXXXXXXXXXXXXXXXXXXX (임의 입력값)
텔레그램  봇파더(BotFather)를 통해서 생성한 Bot 의 API키 값을 복사하여 입력
Configure skills now?
=> no
openclaw의 기본 대화 외에 여러 스킬
goplaces: 구글 지도 검색 (API 키 필요)
browser: 웹 검색 (설정 필요할 수 있음)
code-interpreter: 코드 실행
등 을 사용할 때 필요한 설정
지금은 설치 단계에 있고, 구글 연동만을 위한 것이기 때문에 no 선택 후 패스
Enable hooks?
boot-md (Run BOOT.md on gateway startup)
command-logger (Log all command events to a centralized audit file)
session-memory (Save session context to memory when /new command is issued)
모두 선택(’스페이스 키’) 후 엔터키를 이용해서 다음 단계로
Install shell completion script?
=> Yes
터미널에서 openclaw doc…까지만 치고 [Tab] 키를 누르면 openclaw doctor로 자동 완성해 주는 기능

설정 점검


doctor 옵션을 이용한 점검

npx openclaw doctor
1. 설정 파일 검사
2. 연결 상태 확인
3. 환경 점검
4. 자동 복구
5. 언제 사용?

openclaw 실행


1. 기본 실행 (터미널 수동)
npx openclaw gateway
2. 서비스(daemon)화 실행
2.1 실행 명령어
# PM2가 실행될 때 ~/openclaw 폴더로 이동해서 실행
pm2 start "npx openclaw gateway" --name openclaw --cwd ~/openclaw
npx openclaw 실행 시 “~/openclaw” 로 이동해야 함을 감안한 명령어 설정
2.2 pm2 구동
“2.1 섹션”에서 결정된 명령어로 실행
$ pm2 start "npx openclaw gateway" --name openclaw --cwd ~/openclaw
[PM2] Starting /usr/bin/bash in fork_mode (1 instance)
[PM2] Done.
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 0  │ openclaw           │ fork     │ 0    │ online    │ 0%       │ 40.1mb   │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
2.3 pm2 로 구동된 프로세스 상태 저장
$ pm2 save
[PM2] Saving current process list...
[PM2] Successfully saved in /home/donald/.pm2/dump.pm2
이제부터
pm2 stop
pm2 start
 를 이용한 제어가 가능해짐
2.4 저장된 프로세스 상태로 시작프로그램 스크립트 생성
$ pm2 startup
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u donald --hp /home/donald
$ sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u donald --hp /home/donald

[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target

[Service]
Type=forking
User=donald
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/home/donald/.npm-global/bin:/home/donald/.local/bin:/home/donald/bin:/usr/share/Modules/bin:/usr/bin:/bin:/usr/sbin
Environment=PM2_HOME=/home/donald/.pm2
PIDFile=/home/donald/.pm2/pm2.pid
Restart=on-failure

ExecStart=/usr/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/lib/node_modules/pm2/bin/pm2 kill

[Install]
WantedBy=multi-user.target

텔레그램 접근


허가 받지 않은 텔레그램사용자(id)가 봇에 접속 후 “/start” 요청을 하게되면
대화창 응답 내용

OpenClaw: access not configured.
Your Telegram user id: 75331166
Pairing code: 8A3HIGO0
Ask the bot owner to approve with:
openclaw pairing approve telegram <code>

서버에서
openclaw pairing approve telegram <code>
즉,
openclaw pairing approve telegram 8A3HIGO0
처리 해주라는 의미
서버측에 페어링 요청 발생
요청파일 : telegram-pairing.json
경로 : .openclaw/credentials/telegram-pairing.json
(처음 설치 및 구동시에는 존재하지 않는 파일)
{
  "version": 1,
  "requests": [
    {
      "id": "75331166",
      "code": "8A3HIGO0",
      "createdAt": "2026-02-01T06:23:18.486Z",
      "lastSeenAt": "2026-02-01T06:23:18.486Z",
      "meta": {
        "username": "yourid_plz",
        "firstName": "yourname_plz"
      }
    }
  ]
}
해당 페어링 요청에 대하여 봇 사용 허용
npx openclaw pairing approve telegram 8A3HIGO0
허용 후 파일 생성됨
.openclaw/credentials/telegram-allowFrom.json
{
  "version": 1,
  "allowFrom": [
    "45912865"
  ]
}
대기중인 허용이 완료된 경우 “telegram-pairing.json” 파일에 정의된 값이 초기화 됨
{
  "version": 1,
  "requests": []
}
만약 2개 이상의 유저를 허용해주었다면
{
  "version": 1,
  "allowFrom": [
    "45912865",
    "12345656"
  ]
}
기존 허용id 뒤에 쉼표(‘,’)로 구분 후 기재하는것으로 허용
openclaw 명령 수행 절차가 아닌, 파일을 직접 생성/편집 하는 것으로도 가능하다
Exit mobile version