반응형

 

PiKVM 이란?

PiKVM은 라즈베리 파이(Raspberry Pi)를 이용한 KVM-over-IP 솔루션

  • KVM (Keyboard, Video, Mouse) 기능을 네트워크를 통해 원격으로 제어할 수 있도록 해줍니다.
  • 서버나 PC의 BIOS 설정, OS 설치, 문제 해결 등을 물리적으로 접근하지 않고도 원격에서 수행할 수 있습니다.
  • 라즈베리 파이 + HDMI 캡처 + USB 연결로 간단하게 구축 가능하며, 웹 인터페이스를 제공하여 사용이 편리합니다.

PiKVM 을 쓰려면 일단 라즈베리 파이와 영상 캡쳐를 위한 몇몇 추가 장비가 필요합니다.
성능도 꽤 좋습니다.
그런데 집에 PC가 많으니까 한 PC 에서 다른 PC를 제어하면 되지 않을까? 하면서 찾아봤습니다.
github 에 보면 옛적부터 PiKVM 을 포팅해서 x86kvm 이나 기타 등등 여러가지 있지만 원하는 형태는 잘 안보였습니다만,
최근에 OneKVM 이라고 하나 찾아서 테스트 해보니 괜찮았습니다.

 

OneKVM

일단 중국 친구가 PiKVM 포크해서 만든 것 같고 도커로 실행이 잘 됩니다.
VM 이미지도 제공하는데 테스트 해보니 그것도 잘 됬습니다.
영상 캡쳐는 USB-HDMI 로 사용하고, 키보드 마우스 입력은 USB-TTL 장치와 ch9329 를 이용해서 합니다.

 

준비물

  • 도커 실행 가능 PC
  • KVM 적용할 PC 또는 장치 (클라이언트)
  • USB-TTL (USB UART, ch340 등 아무거나), 1,000원~4,000원
  • CH9329 (UART to HID), 3,000원
  • USB HDMI 캡쳐 카드 (MS2130 등), 5,000 ~ 14,000원
  • 총합 9,000~20,000원
    (가격은 알리익스프레스 보통 판매가이며 할인하면 더 싸게 구할 수 있습니다 )

 

One-KVM 설치

도커로 설치해서 사용하면 됩니다.
저는 docker-compose.yaml 만들어서 사용했습니다.
proxmox 환경에서 lxc 데비안 설치 하였으며 /dev/video0 와 /dev/ttyUSB0 를 passthrough 해서 사용했습니다.

services:
  onekvm:
    container_name: onekvm
    image: silentwind0/kvmd
    devices:
      - /dev/video0:/dev/video0
      - /dev/ttyUSB0:/dev/ttyUSB0
    network_mode: host  # 호스트 네트워크 사용, WebRTC용?
#    ports:
#      - "8080:8080"
#      - "4430:4430"
#      - "5900:5900"
#      - "623:623"
    volumes:
      - ./kvmd_config:/etc/kvmd
    environment:
      - CH9329SPEED=115200
      - USERNAME=KVM_WEB_USER
      - PASSWORD=KVM_WEB_PASSWORD
    restart: unless-stopped

접속 주소는 https://kvm-ip:4430 이며 처음 접속 시 영어로 언어 선택하면 됩니다.

 

USB-TTL 과 CH9329 연결

USB-TTL 과 CH9329 를 연결해주면 됩니다.
TTL CH9329
rx - tx
tx - rx
gnd - gnd
세개 선만 연결하고 vcc 는 연결하지 않습니다.

제가 가진 CH9329 와 CH340 은 생각없이 연결하고 써도 문제 없더군요.
tx 전압 측정해보니 5v 로직전압인듯 합니다.

CH9329 를 원격조종할 PC 에 연결하고, CH340 을 도커 설치할 PC 에 연결,
하드웨어가 인식 잘 되었는지 확인 후
잘 사용하면 됩니다.

 

CH9329 정지 문제 해결

클라이언트 PC 를 재부팅 하거나 하면 CH9329 가 자꾸 먹통이 됩니다.
CH9329 를 reset 시키면 살아납니다. (물리적으로 USB 제거 후 다시 연결, 또는 reset 신호)

x86 pikvm 에서 ch_reset.py 를 실행하면 된다고 해서 vm에 설치하고 파이썬 파일을 가져와서 조금 수정했습니다.
장치에 맞게 device path, serial 설정을 주면 됩니다.

 

도커 내부에 들어가서
python3 ./ch_reset.py
실행해주면 CH9329 가 리셋되면서 다시 사용 가능합니다.
(host 에서 해도 되나 파이썬 라이브러리 설치가 귀찮습니다..)

 

해당 파일은 kvmd_config 에 고이 넣어둡니다. 아래에서 쓰기 쉽게 만들거거든요.

kvmd_config/ch_reset.py

#!/usr/bin/python3
import serial
import time

device_path = "/dev/ttyUSB0"
chip = serial.Serial(device_path, 115200, timeout=1)

command = [87, 171, 0, 15, 0]
sum = sum(command) % 256
command.append(sum)

print("Resetting CH9329")

chip.write(serial.to_bytes(command))

time.sleep(0.2)

data = list(chip.read(5))
print("Initial data:", data)

if data[4] :
        more_data = list(chip.read(data[4]))
        data.extend(more_data)
print("Output: ", data)

chip.close()

실행하기 쉽게 쉘스크립트로 하나 만들어줍니다.

kvmd_config/ch_reset.sh

#!/bin/bash
/usr/local/bin/python3 /etc/kvmd/ch_reset.py

저장 후 실행 가능하게 권한 설정 해주고요
chmod +x ch_reset.sh

 

CH9329 추가 설정

CH9329 통신 속도가 기본값은 9600 인데 115200 으로 바꾸면 조금 더 안정적이라고 합니다.
도커 환경변수에 넣어서 반영 시켰지만 장치 기본값도 바꿔놓으면 좀 더 안정정입니다.

 

아래 링크에서 프로그램을 받아서 CH9329만 USB 에 꽃은 후 실행합니다. (윈도우 PC)
https://www.wch.cn/downloads/CH9329EVT_ZIP.html

메뉴가 다 깨지는데 대충 추측해서 눌러봅니다.
왼쪽 위에서 USB 로 연결되었다고 선택 한 후 연결 시키면 아래 정보가 뜹니다.
오른쪽 버튼 눌러서 불러오고 통신 속도를 115200 으로 바꾸고 다시 저장하면 됩니다.

KVM 에서 mouse jiggler 를 켜놓으면 계속 통신되니 안정적이라는 내용도 있네요.

KVM 메뉴 커스텀

KVM 접속 시 상단에 불필요한 중국어로 된 메뉴가 있어서 커스텀을 조금 했습니다.
위에서 만든 CH HID Reset 을 추가해주고 개인적으로 쓰는 ATX 전원제어 장치(Rest API 동작) 명령어를 넣어줬습니다.

아래 파일을 편집하면 됩니다. 필요한 부분만 수정했습니다. 안쓰는 내용도 좀 있어요.
수정 후 도커 재시작 하고 접속하면 이제 ch_reset 를 메뉴에서 바로 사용 할 수 있습니다.

 

kvmd_config/override.yaml

kvmd:
    auth:
        enabled: true

    atx:
        type: disabled

    hid:
        type: ch9329
        device: /dev/ttyUSB0
        speed: 115200
        read_timeout: 0.3

        jiggler:
            active: true
            enabled: true

        mouse_alt:
            device: /dev/kvmd-hid-mouse-alt

    msd:
        #type: otg
        remount_cmd: /bin/true
        msd_path: /var/lib/kvmd/msd
        normalfiles_path: NormalFiles
        normalfiles_size: 256

    ocr:
        langs:
            - eng
            - chi_sim

    streamer:
        resolution:
            default: 1920x1080

        forever: true

        desired_fps:
            default: 60
            max: 60

        h264_bitrate:
            default: 8000

        cmd:
            - "/usr/bin/ustreamer"
            - "--device=/dev/video0"
            - "--persistent"
            - "--format=mjpeg"
            - "--encoder=LIBX264-VIDEO"
            - "--resolution={resolution}"
            - "--desired-fps={desired_fps}"
            - "--drop-same-frames=30"
            - "--last-as-blank=0"
            - "--unix={unix}"
            - "--unix-rm"
            - "--unix-mode=0666"
            - "--exit-on-parent-death"
            - "--process-name-prefix={process_name_prefix}"
            - "--notify-parent"
            - "--no-log-colors"
            - "--h264-sink=kvmd::ustreamer::h264"
            - "--h264-sink-mode=0660"
            - "--jpeg-sink=kvmd::ustreamer::jpeg"
            - "--jpeg-sink-mode=0660"
            - "--h264-bitrate={h264_bitrate}"
            - "--h264-gop={h264_gop}"
            - "--h264-preset=ultrafast"
            - "--slowdown"
    gpio:
        drivers:
            ch_reset:
                type: cmd
                cmd: [/etc/kvmd/ch_reset.sh, short]
            wol_server1:
                type: wol
                mac: 2c:56:dc:db:7c:1e
            short_press:
                type: cmd
                cmd: [/etc/kvmd/power_control.sh, short]
            long_press:
                type: cmd
                cmd: [/etc/kvmd/power_control.sh, long]
            reset_press:
                type: cmd
                cmd: [/etc/kvmd/atx.sh, reset]
            input1:
                type: cmd
                cmd: [/etc/kvmd/kvm_input.sh, 1]    
            input2:
                type: cmd
                cmd: [/etc/kvmd/kvm_input.sh, 2]
        scheme:
            ch_reset:
                driver: ch_reset
                pin: 0
                mode: output
                switch: false
            wol_server1:
                driver: wol_server1
                pin: 0
                mode: output
                switch: false
            short_button:
                driver: short_press
                pin: 0
                mode: output
                switch: false
            long_button:
                driver: long_press
                pin: 0
                mode: output
                switch: false
            reset_button:
                driver: reset_press
                pin: 0
                mode: output
                switch: false
            input1-button:
                driver: input1
                pin: 0
                mode: output
                switch: false
            input2-button:
                driver: input2
                pin: 0
                mode: output
                switch: false
        view:
            header:
                title: 고급설정
            table:
                - ["#CH HID Reset"]
                - ["ch9329 reset :", ch_reset|실행]
                - ["----------------"]
                - [" "]
                - [" "]
                - [" "]
                - [" "]
                - [" "]
                - ["#ATX 전원제어"]
                - ["#전원버튼(On/Off):", short_button|실행]
                - [" "]
                - [" "]
                - [" "]
                - ["#강제종료(Power 5s):", long_button|실행]


vnc:
    keymap: /usr/share/kvmd/keymaps/en-us
    mouse_output: usb

    auth:
        vncauth:
            enabled: true

    memsink:
        jpeg:
            sink: "kvmd::ustreamer::jpeg"
        h264:
            sink: "kvmd::ustreamer::h264"

media:
    memsink:
        h264:
            sink: 'kvmd::ustreamer::h264'

        jpeg:
            sink: 'kvmd::ustreamer::jpeg'
janus:
    stun:
        host: stun.cloudflare.com
        port: 3478

otgnet:
    commands:
        post_start_cmd:
            - "/bin/true"
        pre_stop_cmd:
            - "/bin/true"

nginx:
    http:
        port: 8080
    https:
        port: 4430

 

 

여기까지 커스텀 완료했습니다.

도커는 영상모드는 mjpeg 만 사용되는데 내부망에서는 빠르고 좋습니다.

HW 패스스루/드라이버/캡쳐USB 문제인 것 같아서 몇번 해보고 포기했습니다.

VM 으로 깔면 WebRTC도 되긴 하는데 별로 좋은지 모르겠습니다.

 

저는 추가로 power_control.sh 에서 전원 버튼 누를때마다 ch_reset.py 실행하는 로직까지 넣어놨습니다.
바이오스 들어가기 한결 편하더라구요.

반응형
반응형

 

Proxmox 에 윈도우 VM 을 올려놓았는데

사용하지 않을때는 종료 시켜 놓는다.

그런데 짝꿍은 Proxmox 접근 권한이 없으니까...HA 에 전원 버튼을 만들어줬다.

 

 

참조 글은 아래 링크

https://www.jamescoyle.net/tag/api

 

API | JamesCoyle.net Limited

Proxmox has 2 API access points that can be used to control your Proxmox server and virtual guests. One of the API access points is using the command line, which you’re likely already familiar with. The other is the HTTP web API which is exposed as part

www.jamescoyle.net

 

 

대충 아래 내용들을 채워 넣어야 한다

  • TICKET is the authentication ticket that was produced in the Parse Proxmox Web API authentication ticket and the CSRFPreventionToken in Bash post. Ideally you would programatically call the authentication routine and then pass the values straight into the below API calls.
  • CSRF is produced in the same way as TICKET. It’s actually only required when writing data to the API but there is no harm in always including it.
  • HOST is the host or IP address of the Proxmox server.
  • NODE is the node name of the Proxmox server that the LXC Container resides on.
  • TARGET_VM  is the VMID of the LXC Container.

 

 

 

Proxmox 웹에 접속한 후에

Datacenter 선택 후

Permission -> User -> add 로 사용자를 하나 추가하고 아이디/암호 기억하자

 

 

Permission -> Roles 에서 Create 로 API 용 role 을 하나 추가해주자

 

proxmox host shell 에 접속해서 아래와 같은 명령어로 role 을 부여해주자.

pveum acl modify / -user API@pve -role APIrole

 

이제 아래와 같은 스크립트를 만들면 된다. 중간 5줄만 잘 채우자.

VM 시작 스크립트

VMwin10Start.sh

#!/bin/bash

decodeDataFromJson(){
    echo `echo $1 \
            | sed 's/{\"data\"\:{//g' \
            | sed 's/\\\\\//\//g' \
            | sed 's/[{}]//g' \
            | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' \
            | sed 's/\"\:\"/\|/g' \
            | sed 's/[\,]/ /g' \
            | sed 's/\"// g' \
            | grep -w $2 \
            | awk -F "|" '{print $2}'`
}

PROX_USERNAME=user@pve
PROX_PASSWORD=password
HOST=proxmox_host_ip
NODE=proxmox_node
TARGET_VMID=VM_number

DATA=`curl -s -k -d "username=$PROX_USERNAME&password=$PROX_PASSWORD" $HOST/api2/json/access/ticket`
TICKET=$(decodeDataFromJson $DATA 'ticket')
CSRF=$(decodeDataFromJson $DATA 'CSRFPreventionToken')


START_TASK_DATA=`curl -s -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" -X POST $HOST/api2/json/nodes/$NODE/qemu/$TARGET_VMID/status/start`

 

VM 종료 스크립트

VMwin10Shutdown.sh

#!/bin/bash

decodeDataFromJson(){
    echo `echo $1 \
            | sed 's/{\"data\"\:{//g' \
            | sed 's/\\\\\//\//g' \
            | sed 's/[{}]//g' \
            | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' \
            | sed 's/\"\:\"/\|/g' \
            | sed 's/[\,]/ /g' \
            | sed 's/\"// g' \
            | grep -w $2 \
            | awk -F "|" '{print $2}'`
}

PROX_USERNAME=user@pve
PROX_PASSWORD=password
HOST=proxmox_host_ip
NODE=proxmox_node
TARGET_VMID=VM_number

DATA=`curl -s -k -d "username=$PROX_USERNAME&password=$PROX_PASSWORD" $HOST/api2/json/access/ticket`
TICKET=$(decodeDataFromJson $DATA 'ticket')
CSRF=$(decodeDataFromJson $DATA 'CSRFPreventionToken')


START_TASK_DATA=`curl -s -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" -X POST $HOST/api2/json/nodes/$NODE/qemu/$TARGET_VMID/status/shutdown`

 

 

해당 스크립트를 HA config 폴더에 넣고

configuration.yaml 파일에 아래와 같은 shell 커맨드를 넣어준다.

shell_command:
  win10start: sh VMwin10Start.sh
  win10stop: sh VMwin10Shutdown.sh

 

이제 요렇게 추가 완료

전원 켜짐은 device_tracker 로 알아서 만들기

반응형
반응형

아래 링크대로 진행하면 잘 된다.

 

https://www.kreaweb.be/diy-home-server-2021-software-proxmox-ups/

 

DIY HOME SERVER 2021 - Software - PROXMOX - NUT UPS Monitoring | KREAWEB

When building a home lab server, you’re almost always going to use some kind of Uninterruptible Power Supply (UPS). Let's install some tools to monitor the system.

www.kreaweb.be

 

 

usb 가 porxmox 장치에 연결되어 있는 환경에서

 

대충 요약하면

 

USB 포트에 맞게 연결되어 있는지 확인하고

lsusb
lsusb -v -s [bus]:[device]

 

NUT 를 설치해주고

apt install nut -y

NUT 디바이스를 확인한다. 

nut-scanner -U

 

 

기본 설정 파일 백업은 생략한다.

 

파일 수정

nano /etc/nut/nut.conf

아래 내용만 입력 

MODE=netserver

 

파일 수정

nano /etc/nut/ups.conf

 

pollinterval = 15
maxretry = 3

offdelay = 120
ondelay = 240

[ups] 
# APC Back-UPS BX1400U-FR
driver = usbhid-ups
port = auto
desc = "APC Back-UPS BX1400U-FR"
vendorid = 051D
productid = 0002
serial = secret

 

ups 드라이버 시작

upsdrvctl start

 

파일 수정

nano /etc/nut/upsd.conf
LISTEN 0.0.0.0 3493
LISTEN :: 3493

 

nano /etc/nut/upsd.users
[upsadmin]
# Administrative user
password = ********
# Allow changing values of certain variables in the UPS.
actions = SET
# Allow setting the "Forced Shutdown" flag in the UPS.
actions = FSD
# Allow all instant commands
instcmds = ALL
upsmon master

[monuser]
# Normal user
password = ********
upsmon slave

 시놀로지에서 쓰려면 monuser 암호를 secret 으로 하면 된다.

 

nano /etc/nut/upsmon.conf
RUN_AS_USER root
MONITOR ups@localhost 1 upsadmin ******* master

MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h"
NOTIFYCMD /usr/sbin/upssched
POLLFREQ 4
POLLFREQALERT 2
HOSTSYNC 15
DEADTIME 24
MAXAGE 24
POWERDOWNFLAG /etc/killpower

NOTIFYMSG ONLINE "UPS %s on line power"
NOTIFYMSG ONBATT "UPS %s on battery"
NOTIFYMSG LOWBATT "UPS %s battary is low"
NOTIFYMSG FSD "UPS %s: forced shutdown in progress"
NOTIFYMSG COMMOK "Communications with UPS %s established"
NOTIFYMSG COMMBAD "Communications with UPS %s lost"
NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding"
NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced"
NOTIFYMSG NOCOMM "UPS %s is unavailable"
NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible"

NOTIFYFLAG ONLINE   SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT   SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT  SYSLOG+WALL+EXEC
NOTIFYFLAG FSD      SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK   SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD  SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL
NOTIFYFLAG NOCOMM   SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL

RBWARNTIME 43200
NOCOMMWARNTIME 600

FINALDELAY 5

 

 

nano /etc/nut/upssched.conf
CMDSCRIPT /etc/nut/upssched-cmd
PIPEFN /etc/nut/upssched.pipe
LOCKFN /etc/nut/upssched.lock

AT ONBATT * START-TIMER onbatt 30
AT ONLINE * CANCEL-TIMER onbatt online
AT ONBATT * START-TIMER earlyshutdown 30
AT LOWBATT * EXECUTE onbatt
AT COMMBAD * START-TIMER commbad 30
AT COMMOK * CANCEL-TIMER commbad commok
AT NOCOMM * EXECUTE commbad
AT SHUTDOWN * EXECUTE powerdown
AT SHUTDOWN * EXECUTE powerdown

 

nano /etc/nut/upssched-cmd
#!/bin/sh
 case $1 in
       onbatt)
          logger -t upssched-cmd "UPS running on battery"
          ;;
       earlyshutdown)
          logger -t upssched-cmd "UPS on battery too long, early shutdown"
          /usr/sbin/upsmon -c fsd
          ;;
       shutdowncritical)
          logger -t upssched-cmd "UPS on battery critical, forced shutdown"
          /usr/sbin/upsmon -c fsd
          ;;
       upsgone)
          logger -t upssched-cmd "UPS has been gone too long, can't reach"
          ;;
       *)
          logger -t upssched-cmd "Unrecognized command: $1"
          ;;
 esac
chmod +x /etc/nut/upssched-cmd

 

아래 명령어로 이제 시작해주자.

service nut-server restart
service nut-client restart
systemctl restart nut-monitor
upsdrvctl stop
upsdrvctl start

 

ups 연결 확인 가능

upsc ups@localhost

 

 

이제 synology 에서도 ip 확인 가능...

반응형
반응형

 

서브로 사용하는 시놀로지(헤놀)에 duckdns의 dns challenge 로 인증서를 설정해봤다.

 

최근 acme 기본 서버가 zerossl 인데 뭔가 설정이 잘 안되서 삽질을 한참 했다.

 

 

테스트 환경은

synology 920+ 에 duckdns 얹어서 letsencrypt 로 인증서 받기

 

 

참조 문서 목록

https://www.clien.net/service/board/cm_nas/17436459

 

ACME를 이용한 와일드카드 인증서 시놀로지 발급 관련 자료 모음 : 클리앙

이번에 나스를 옮기면서 삽질을 여러번 했습니다. 1. 기존 나스에 설정해두었던 ACME설치방법을 완전히 까먹었었다는 것이 사건의 발단이었고 2. ACME 방식이 약간 변경이 있었다는 것 3. DSM7에서는

www.clien.net

 

https://github.com/acmesh-official/acme.sh/tree/master/dnsapi

 

GitHub - acmesh-official/acme.sh: A pure Unix shell script implementing ACME client protocol

A pure Unix shell script implementing ACME client protocol - GitHub - acmesh-official/acme.sh: A pure Unix shell script implementing ACME client protocol

github.com

 

https://github.com/acmesh-official/acme.sh/wiki/Synology-NAS-Guide

 

Synology NAS Guide

A pure Unix shell script implementing ACME client protocol - acmesh-official/acme.sh

github.com

 

https://siane.tistory.com/267

 

[Synology] 시놀로지에서 클라우드플레어 DDNS 설정하고 와일드카드 인증서 받기 #2

2021.10.01 - [Synology] 시놀로지에서 클라우드플레어 DDNS 설정하고 와일드카드 인증서 받기 #1 이 게시글의 연장입니다. 사용 환경은 DS1821+, DSM 7.0.1 입니다. 6.2 호환성에 대해서는 확인되지 않았습니

siane.tistory.com

 

 

  1. DSM 인증서 발급을 위한 사용자를 추가하고 시작하자. administrator 그룹에 포함 필요.
    (아니면 관리자 권한 있는 기존 사용자 사용해도 된다)
  2. DSM 에서 ssh 포트를 사용 가능하도록 하고 putty나 기타 등등 이용하여 ssh 접속해준다.
  3. 이제 ssh 에서 아래 명령어를 순서대로 입력한다. 중간에 sudo 명령어로 인해 암호를 다시 물어봄.
wget -O /tmp/acme.sh.zip https://github.com/acmesh-official/acme.sh/archive/master.zip


#acme 설치
sudo 7z x -o/usr/local/share /tmp/acme.sh.zip
sudo mv /usr/local/share/acme.sh-master/ /usr/local/share/acme.sh
sudo chown -R certadmin /usr/local/share/acme.sh/
cd /usr/local/share/acme.sh


#acme 업데이트
./acme.sh --force --upgrade --nocron --home /usr/local/share/acme.sh

# 이메일 계정 추가
./acme.sh --install --nocron --home /usr/local/share/acme.sh --accountemail "email@gmailcom"

#acme 기본 서버 letsencrypt 로 변경 
./acme.sh --set-default-ca --server letsencrypt

# 개인 도메인, 토큰 입력
export CERT_DNS='dns_duckdns'
export DuckDNS_Token='xxx-xxx'
export $CERT_Domain='your_domain'

#인증서 받아오기
./acme.sh --server letsencrypt --issue --home . -d '$CERT_Domain' --dns '$CERT_DNS'

#시놀로지 user id 와 암호를 입력해준다.
#만약 DSM 포트를 바꾸었으면 바꾼 포트도 넣어준다.
# certificate 항목 내용과 동일한 인증서를 갱신해준다.
export SYNO_Username='username'
export SYNO_Password='password'
export SYNO_Certificate='설명'
export SYNO_Port='DSM_http_port'
export SYNO_Create=1

# DSM 에 기본 인증서로 등록해준다. 
./acme.sh --deploy --home . -d ksdrive.duckdns.org --deploy-hook synology_dsm

 

 

인증서 갱신은 아래와 같은 명령어를 쓰면 된다.

제어판 -> 작업 스케쥴러 에서 생성해서 추가하면된다. 대충 매주 한번씩 체크하도록 하면 될듯 하다.

/usr/local/share/acme.sh/acme.sh --cron --home /usr/local/share/acme.sh/
반응형
반응형

 

Proxmox 7.0 CT 컨테이너에서 Intel CPU 내장 GPU 가속을 이용하여 plex hw 트랜스코딩 사용을 해보았다.

 

테스트 기기는 j4005 CPU 사용으로 4k 10bit 까지 디코딩이 된다고는 써있는데 잘 안되더란...

 

 

일단 host 에서 정상적으로 그래픽카드가 인식이 되어야 한다.

vainfo 명령어로 봤을 때 아래처럼 나왔다.

root@nuc:~# vainfo
error: can't connect to X server!
libva info: VA-API version 1.10.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_10
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.10 (libva 2.10.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 21.1.1 ()
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

아래 내용도 확인한다.

root@nuc:~# ls -l /dev/dri
total 0
drwxr-xr-x 2 root root         80 Aug 16 20:47 by-path
crw-rw---- 1 root video  226,   0 Aug 16 20:47 card0
crw-rw---- 1 root render 226, 128 Aug 16 20:47 renderD128

 

ubuntu 20.04 버전 CT templet 을 받아서 설치한다. priviliged 모드를 사용할 것. 

이제 설정 파일에 아래 내용을 추가해준다. (내 경우에는 CT번호가 101이다)

nano /etc/pve/lxc/101.conf 

lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.cgroup2.devices.allow: c 29:0 rwm
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file
lxc.autodev: 1
lxc.hook.autodev: sh -c "mknod -m 0666 ${LXC_ROOTFS_MOUNT}/dev/fuse c 10 229"

위에 다섯줄은 intel gpu passthrough 을 위한 내용이고

마지막 두줄은 컨테이너 내에서 fuse 를 사용하기 위한 내용이다. (mount 용도)

 

중요한점은 proxmox 7.0 에서는 lxc.cgroup2 를 사용해야 한다는 내용이다..

하루종일 삽질했네..

 

 

참조 글

https://forum.proxmox.com/threads/pve-7-0-lxc-intel-quick-sync-passtrough-not-working-anymore.92025/

 

[SOLVED] - PVE 7.0 LXC Intel Quick Sync passtrough not working anymore

TLDR: lxc.cgroup.devices.allow MUST be changed to lxc.cgroup2.devices.allow https://forum.proxmox.com/threads/pve-7-0-lxc-intel-quick-sync-passtrough-not-working-anymore.92025/post-400916 Hi, with PVE 6.4, adding these lines to /etc/pve/lxc/.conf was enoug

forum.proxmox.com

 

https://forum.proxmox.com/threads/solved-nuc10-gpu-passthrough-pve-6-3.82023/

 

[SOLVED] - NUC10 GPU Passthrough (PVE 6.3)

Hi folks, I've one last niggle with my proxmox setup, and I'm hoping someone here can guide me to a solution. I have a cluster of 3 x NUC10 boxes, these are Frost Canyon CPUs with Intel UHD Graphics. I want to pass the Intel GPU down to one of my LXC conta

forum.proxmox.com

 

반응형
반응형

종종 ADB 연결 후 파일을 수정하고 싶은데 에디터가 설치되어 있지 않은 안드로이드 장치가 있을 경우 난감하다.

설치가 쉬울텐데 방법을 검색하니 이상한 것들이 많이 나와서 한글로 정리해본다.

 

 

보통의 경우 아래와 같이 사용하면 된다.

adb shell
busybox vi

 

 

vi가 불편할 경우 nano를 아래와 같이 간단하게 설치하고 사용할 수 있다.

먼저 아래 nano를 받고 압축을 풀어서 윈도우 명령 프롬프트로 압축 해제한 폴더에 가서 아래와 같이 진행하면 된다.

nanoforandroid.zip
0.53MB

이제 adb 로 root 권한으로 접속한 후 아래 명령어로 복사하고 권한주고 시스템 설정을 해주면 된다.

adb push nanoforandroid /mnt/sdcard/Download
adb shell
su
mount -o rw,remount /system
cp /sdcard/Download/nanoforandroid/etc/profile /system/etc
cp -r /sdcard/Download/nanoforandroid/etc/terminfo /system/etc
cp /sdcard/Download/nanoforandroid/xbin/nano /system/xbin
chmod 755 -R /system/etc/terminfo
chmod 755 /system/xbin/nano
chmod 755 /system/etc/profile
export TERMINFO=/system/etc/terminfo;export TERM=linux

 

다만 환경변수(export)가 자동으로 저장되지 않아서 접속할때마다 마지막줄을 입력해야 한다.

 

nano editor 사용법은 다양하지만 세개정도만 기억해 주면 됩니다.

  • Ctrl+X  종료
  • Ctrl+O  저장
  • Ctrl+K  현재 행 삭제

더 자세한 내용은 아래 위키 참조해주세요.

https://zetawiki.com/wiki/Nano_%EB%8B%A8%EC%B6%95%ED%82%A4

 

 

이상 끝.

반응형
반응형

시놀로지 라우터를 위한 스크립트 모음이 있다.

사용을 위해서는 라우터에 usb 나 sdcard 와 같은 메모리가 ext3 format 으로 사용중이어야 한다.

 

아래 링크에서 확인하면 된다.

https://gitlab.com/Kendek/syno-router-scripts/-/blob/master/README.md#wireguard_installsh

 

 

 

1. 설치

라우터에서 ssh 접속이 가능하도록 한 후

ssh 로 접속한다.

로그인은 root 계정으로 한다. (admin 계정이 아님!! 암호는 admin 계정과 동일)

 

로그인 후 아래 내용을 입력하면 자동으로 설치 스크립트 창이 뜬다.

sh -c "$(wget -O- goo.gl/Pkyohd)"

 

 

 

WireGuard VPN 설치를 위해서 먼저 사용 할 수 있는 환경을 설치해야 하는데

1번 entware나 2번 ubuntu 아무거나 설치해도 된다.

설치 후 5번 wireguard 를 눌러서 설치하면 된다.

 

 

 

2. 라우터 방화벽 설정

wiregurad 사용을 위해서는 시놀로지 라우터에서 방화벽 설정을 아래와 같이 해주어야 한다.

Necessary firewall rule for connection:

Protocol Source IP Source port Destination IP Destination port Action

UDP All All SRM 51820 Allow

Necessary firewall rule for access to local network:

Protocol Source IP Source port Destination IP Destination port Action

TCP/UDP 10.7.0.0/255.255.255.0 All All All Allow

 

 

3. client 용 설정 파일, QR code 확인

다시 스크립트 접속 후 5번 메뉴 wireguard 에 들어가서 client 추가를 하면 자동으로 설정 및 qrcode 생성이 된다.

생성된 설정 파일 및 QR code는 라우터에 저장되며 라우터 file station 또는 다른 방식으로 접근해서 확인하면 된다.

 

 

 

4. VPN client 설정

안드로이드는 구글 스토어에서 wireguard 를 설치하고 위에서 만든 QR코드를 리딩하기만 하면 자동으로 추가된다.

그리고 바로 사용 가능하다.

윈도우의 경우에는 위에서 만든 컨피그 파일을 불러오면 된다.

참조를 위해 아래 링크도 남겨놓는다.

 

 

 

 

참조할만한 링크

https://golb.hplar.ch/2019/07/wireguard-windows.html

 

Setting up WireGuard on Windows

A few months ago, I wrote a tutorial on how to install WireGuard, a simple, fast, and modern VPN, on Linux and open a VPN connection from an Android device. Because I work most time on Windows I was also especially interested in connecting my computer to a

golb.hplar.ch

https://serversideup.net/generating-wireguard-qr-codes-for-fast-mobile-deployments/

 

Generating Wireguard QR codes for fast mobile deployments - Server Side Up

Supporting mobile devices with Wireguard VPN can be dramatically easier by using a QR code. Learn how to generate a Wireguard QR code for your clients in just a few minutes.

serversideup.net

https://serversideup.net/how-to-configure-a-wireguard-ios-client/

 

How to configure a Wireguard iOS client - Server Side Up

This is a coniutation of my free “mini-course” called Gain Flexibility & Increase Privacy with Wireguard VPN. Start there if you are new to Wireguard. What you’ll achieve We will have our iPhone client connecting to our Wireguard VPN server This is w

serversideup.net

https://serversideup.net/how-to-configure-a-wireguard-android-vpn-client/

 

How to configure a Wireguard Android VPN Client - Server Side Up

Learn how to easily configure a Wireguard Android client. Using QR codes, I'll show you how you to easily configure a remote device in minutes.

serversideup.net

 

https://ziwon.github.io/post/wireguard/

 

WireGuard 설치 및 방화벽 설정 | ziwon.github.io

WireGuard 소개 WireGuard는 임베디드 인터페이스와 슈퍼 컴퓨터를 위한 범용 VPN로, 최첨단 암호화 기술을 사용하며 단순하고 빠르고 현대적인 VPN이다. IPsec보다 더 간단하며 더 빠르고, OpenVPN보다 성�

ziwon.github.io

 

https://www.wireguard.com/quickstart/

 

Quick Start - WireGuard

Quick Start You'll first want to make sure you have a decent grasp of the conceptual overview, and then install WireGuard. After that, read onwards here. Side by Side Video Before explaining the actual comands in detail, it may be extremely instructive to

www.wireguard.com

 

반응형
반응형

ssh로 접속 후 wireguard 설치

repository가 등록되어 있지 않아서 아래와 같이 추가하여 설치하자 

sudo add-apt-repository ppa:wireguard/wireguard

 

sudo apt install wireguard

 

서버 공개키 개인키 생성

sudo mkdir -p /etc/wireguard/server; wg genkey | sudo tee /etc/wireguard/server/server.key | wg pubkey | sudo tee /etc/wireguard/server/server.key.pub

서버 공개키 출력

 

 

공개키 개인키 재확인

cat /etc/wireguard/server/server.key.pub
cat /etc/wireguard/server/server.key

 

서버 설정파일 제작 

sudo nano /etc/wireguard/wg0.conf

 

[Interface]
Address = 192.168.2.1/32
PrivateKey = Server_private_key
ListenPort = 1194

[Peer]
PublicKey = Client_1_public_key
AllowedIPs = 192.168.2.2/32
  • Address: VPN 접속시 서버 IP 주소
  • PrivateKey: 서버의 개인키
  • ListenPort: 사용 포트 (방화벽 에서 열어줘야함, 공유기 사용시 포트포워딩 필요)
  • PublicKey: 접속에 사용하는 client(PC나 모바일폰)의 PublicKey
  • AllowedIPs: client 할당 IP

 

모바일용 QR 코드 제작을 위한 설정

 

qrencode 설치

sudo apt install qrencode

 

QR코드용 공개키 개인키 생성 후 확인

sudo mkdir -p /etc/wireguard/clients; wg genkey | sudo tee /etc/wireguard/clients/mobile.key | wg pubkey | sudo tee /etc/wireguard/clients/mobile.key.pub
cat /etc/wireguard/clients/mobile.key

위쪽 박스: 공개키

아래쪽 박스: 개인키

 

 

QR코드용 설정파일 제작

sudo nano /etc/wireguard/clients/mobile.conf
[Interface]
PrivateKey = Mobile_Private_key
Address = 192.168.2.3/24
DNS = 1.1.1.1, 1.0.0.1

[Peer]
PublicKey = YOUR_SERVER_PUBLIC_KEY
AllowedIPs = 0.0.0.0/0
Endpoint = YOUR_SERVER_WAN_IP:1194
  • Endpoint: 서버IP (또는 DDNS 주소 사용 가능)

 

서버 설정파일에 Peer 추가

sudo nano /etc/wireguard/wg0.conf
[Interface]
Address = 192.168.2.1/32
PrivateKey = Server_private_key
ListenPort = 1194

[Peer]
PublicKey = Client_1_public_key
AllowedIPs = 192.168.2.2/32

[Peer]
PublicKey = Mobile_public_key
AllowedIPs = 192.168.2.3/32

 

QR 코드 생성

qrencode -t ansiutf8 < /etc/wireguard/clients/mobile.conf

 

Wireguard 실행

wg-quick up wg0

 

이제 생성된 QR 코드를 소중하게 잘 보관하고 wireguard android 앱에서 QR스캔하면 접속 가능!

 

 

 

 

Wireguard 가 실행되어 있을 경우에는 아래와 같이 재시작 필요

wg-quick down wg0 && wg-quick up wg0

 

시스템 재시작시 자동 실행 등록

sudo systemctl enable wg-quick@wg0

Synology NAS의 경우 제어판-작업스케줄러에 시작시 아래와 같이 실행하도록 설정

sleep 60
wg-quick up wg0
sleep 5
wg-quick down wg0
sleep 5
wg-quick up wg0

 

 

 

 

 

 

 

윈도우에서는 아래와 같이 설정되어야 함 참조하여 윈도우 client 셋팅하고 서버 설정파일에 키를 잘 넣어주자.

 

이상 끝

 

 

참조할만한 링크

https://golb.hplar.ch/2019/07/wireguard-windows.html

 

Setting up WireGuard on Windows

A few months ago, I wrote a tutorial on how to install WireGuard, a simple, fast, and modern VPN, on Linux and open a VPN connection from an Android device. Because I work most time on Windows I was also especially interested in connecting my computer to a

golb.hplar.ch

https://serversideup.net/generating-wireguard-qr-codes-for-fast-mobile-deployments/

 

Generating Wireguard QR codes for fast mobile deployments - Server Side Up

Supporting mobile devices with Wireguard VPN can be dramatically easier by using a QR code. Learn how to generate a Wireguard QR code for your clients in just a few minutes.

serversideup.net

https://serversideup.net/how-to-configure-a-wireguard-ios-client/

 

How to configure a Wireguard iOS client - Server Side Up

This is a coniutation of my free “mini-course” called Gain Flexibility & Increase Privacy with Wireguard VPN. Start there if you are new to Wireguard. What you’ll achieve We will have our iPhone client connecting to our Wireguard VPN server This is w

serversideup.net

https://serversideup.net/how-to-configure-a-wireguard-android-vpn-client/

 

How to configure a Wireguard Android VPN Client - Server Side Up

Learn how to easily configure a Wireguard Android client. Using QR codes, I'll show you how you to easily configure a remote device in minutes.

serversideup.net

 

https://ziwon.github.io/post/wireguard/

 

WireGuard 설치 및 방화벽 설정 | ziwon.github.io

WireGuard 소개 WireGuard는 임베디드 인터페이스와 슈퍼 컴퓨터를 위한 범용 VPN로, 최첨단 암호화 기술을 사용하며 단순하고 빠르고 현대적인 VPN이다. IPsec보다 더 간단하며 더 빠르고, OpenVPN보다 성�

ziwon.github.io

 

https://www.wireguard.com/quickstart/

 

Quick Start - WireGuard

Quick Start You'll first want to make sure you have a decent grasp of the conceptual overview, and then install WireGuard. After that, read onwards here. Side by Side Video Before explaining the actual comands in detail, it may be extremely instructive to

www.wireguard.com

 

 

사족. 서버와 라우터의 방화벽 설정을 잘 해야 한다. 해당 포트들 오픈이 안되있으면 연결이 안됨

반응형

+ Recent posts