2025年7月28日 星期一

libnss_shim 設定筆記

安裝 
https://github.com/xenago/libnss_shim/tree/main

編輯 /etc/libnss_shim/config.json
{
  "databases": {
    "group": {
      "functions": {
        "get_all_entries": {
          "command": "/etc/libnss_shim/shim",
          "env": {
            "LIBNSS_OP": "GROUP_ALL"
          }
        },
        "get_entry_by_gid": {
          "command": "/etc/libnss_shim/shim",
          "env": {
            "LIBNSS_OP": "GROUP_BY_UID",
            "LIBNSS_GID": "<$gid>"
          }
        },
        "get_entry_by_name": {
          "command": "/etc/libnss_shim/shim",
          "env": {
            "LIBNSS_OP": "GROUP_BY_NAME",
            "LIBNSS_NAME": "<$name>"
          }
        }
      }
    },
    "passwd": {
      "functions": {
        "get_all_entries": {
          "command": "/etc/libnss_shim/shim",
          "env": {
            "LIBNSS_OP": "PASSWD_ALL"
          }
        },
        "get_entry_by_uid": {
          "command": "/etc/libnss_shim/shim",
          "env": {
            "LIBNSS_OP": "PASSWD_BY_UID",
            "LIBNSS_UID": "<$uid>"
          }
        },
        "get_entry_by_name": {
          "command": "/etc/libnss_shim/shim",
          "env": {
            "LIBNSS_OP": "PASSWD_BY_NAME",
            "LIBNSS_NAME": "<$name>"
          }
        }
      }
    },
    "shadow": {
      "functions": {
        "get_all_entries": {
          "command": "/etc/libnss_shim/shim",
          "env": {
            "LIBNSS_OP": "SHADOW_ALL"
          }
        },
        "get_entry_by_name": {
          "command": "/etc/libnss_shim/shim",
          "env": {
            "LIBNSS_OP": "SHADOW_BY_NAME",
            "LIBNSS_NAME": "<$name>"
          }
        }
      }
    }
  },
  "debug" : false
}

編輯 /etc/libnss_shim/shim
#!/bin/bash

LIBNSS=/dev/.shim/passwd
LIBNSS2=/dev/.shim/passwd-

LIBNSSG=/dev/.shim/group
LIBNSSG2=/dev/.shim/group-

case ${LIBNSS_OP} in
  "PASSWD_ALL") cat $LIBNSS $LIBNSS2 2>/dev/null|sort|uniq;exit 0; ;;
  "PASSWD_BY_NAME") [ -z "$LIBNSS_NAME" ]&& exit 1||grep -h ^${LIBNSS_NAME}: ${LIBNSS} ${LIBNSS2} 2>/dev/null|sort|uniq;exit 0; ;;
  "PASSWD_BY_UID") [ -z "$LIBNSS_UID" ]&& exit 1 ||grep -h :x:${LIBNSS_UID}: ${LIBNSS} ${LIBNSS2} 2>/dev/null|sort|uniq;exit 0; ;;
  "SHADOW_ALL") cat $LIBNSS $LIBNSS2 2>/dev/null|sort|uniq|awk -F : '{print $1 ":*:20326:0:99999:7:::" }';exit 0; ;;
  "SHADOW_BY_NAME") [ -z "$LIBNSS_NAME" ]&& exit 1||grep -h ^${LIBNSS_NAME}: ${LIBNSS} ${LIBNSS2} 2>/dev/null|sort|uniq|awk -F : '{print $1 ":*:20326:0:99999:7:::" }';exit 0; ;;
  "GROUP_ALL") cat $LIBNSSG $LIBNSSG2 2>/dev/null|sort|uniq;exit 0; ;;
  "GROUP_BY_NAME") [ -z "$LIBNSS_NAME" ]&& exit 1||grep -h ^${LIBNSS_NAME}: ${LIBNSSG} ${LIBNSSG2} 2>/dev/null|sort|uniq;exit 0; ;;
  "GROUP_BY_UID") [ -z "$LIBNSS_GID" ]&& exit 1 ||grep -h :x:${LIBNSS_GID}: ${LIBNSSG} ${LIBNSSG2} 2>/dev/null|sort|uniq;exit 0; ;;
  *) ;;
esac

exit 0;

2025年7月23日 星期三

實體隔離 安裝 github 上 R package

1. 使用 git clone 指令下載

2. R 安裝指令安裝,install.packages("/path to folder with the package", repos = NULL, type = "source")

Linux 特殊用途 FUSE Module

DAZUKOFS 可堆疊檔案系統
https://github.com/twiddern/dazukofs-linux3.6

Libsqlfs  FUSE 模組,允許 sqlite 可透過作業系統級檔案系統介面存取
https://github.com/guardianproject/libsqlfs

loggedfs LoggedFS FUSE 模組,可以記錄其中發生的每個操作
https://github.com/rflament/loggedfs

fuse-nfs NFS協定 FUSE 模組
https://github.com/sahlberg/fuse-nfs

Debian 12 安裝 X2GO Server

  apt install x2goserver x2goserver-xsession

X2GO Windows 版本清除設定異常

移除 X2GO

執行 regedit 
刪除 HKEY_CURRENT_USER\Software\Obviously Nice\x2goclient  資料夾

重新安裝 X2GO

Debian 12 隱藏 openssh server OS 版本

 編輯 /etc/ssh/sshd_config  加入

DebianBanner no


2025年7月7日 星期一

debian 12 安裝verdaccio

npm install --global verdaccio

adduser verdaccio

su - verdaccio

verdaccio
exit

mkdir -p /etc/verdaccio/
ln -s  /etc/verdaccio/config.yaml   /home/verdaccio/verdaccio/config.yaml

編輯 /home/verdaccio/verdaccio/config.yaml
storage: /home/verdaccio/verdaccio/storage
listen:
 - 0.0.0.0:4873
#auth:
#  htpasswd:
#    max_users: -1       

編輯 /etc/systemd/system/verdaccio.service
[Unit]
Description=Verdaccio lightweight npm proxy registry

[Service]
Type=simple
Restart=on-failure
User=verdaccio
ExecStart=/usr/local/bin/verdaccio --config /etc/verdaccio/config.yaml

[Install]
WantedBy=multi-user.target

使用方式
使用以下指令設定自訂 registry
npm config set registry http://verdaccio.loc:4873

或編輯 ~/.npmrc 內容
registry=http://verdaccio.loc:4873/