NTPWEdit可解主機”此工作站和主要網域間的信任關係失敗”
這個我也不知道怎回事, 反正解法是想辦法用本地端帳號登入, 用NTPWEdit(點此下載)這款軟件, 搭配優啟通, 或是 usbox 開機碟製作工具, 先做出開機碟再開機->執行 NTPWEdit->選擇 C:\WINDOWS\SYSTEM32\CONFIG\SAM 改掉裡面本機帳號之密碼, 重開就可以本機帳號登入,
登入後, 先退出網域, 再重新加入網域, 就可以挽回網域主控站的心, 重新認可這台主機了
這個我也不知道怎回事, 反正解法是想辦法用本地端帳號登入, 用NTPWEdit(點此下載)這款軟件, 搭配優啟通, 或是 usbox 開機碟製作工具, 先做出開機碟再開機->執行 NTPWEdit->選擇 C:\WINDOWS\SYSTEM32\CONFIG\SAM 改掉裡面本機帳號之密碼, 重開就可以本機帳號登入,
登入後, 先退出網域, 再重新加入網域, 就可以挽回網域主控站的心, 重新認可這台主機了
Wireguard 與最近大熱門的ChatGPT一樣, 是邪惡的存在, 以往公司網管還能勉強管控員工自架VPN, P2P, 與遠端連線, 雖說辛苦,但員工相關網路行為終究掌握在手中.
現在不得了了, 使用wireguard技術的 Tailscale 已攔不住, 隨隨便便就能翻牆, 穿透內網. 我們網管就像是鯀, 治水用阻擋的方式不再可行 , 該是要全面開放, 採用全面零信任的思維+員工契約進行資通安全的管控.
“新暗網時代” , 用wireguard, 能讓一個小群體, 自成一個暗網, 也可自行打造VPN暗黑王國, 市面上網紅推薦的乾爹乾爸VPN, 未來亦將勢微.
本文著重在翻牆, 與簽入公司內部網路, 若用來做site to site請參考以下 tailscale 建議, 直接用Wireguard 比較好.
Using WireGuard directly offers better performance than using Tailscale. Tailscale does more than WireGuard, so that will always be true. We aim to minimize that gap, and Tailscale generally offers good bandwidth and excellent latency, particularly compared to non-WireGuard VPNs.
環境
架設Headscale+UI
# 存放headscale設定檔按
mkdir -p /root/headscale/config
mkdir -p /root/headscale/data
# 虛擬網路
docker network create reverseproxy-nw
vi /root/headscale/docker-compose.yml
###############################################################################
version: '3.5'
services:
headscale:
image: headscale/headscale:0.21
container_name: headscale
volumes:
- '~/config:/etc/headscale'
- '~/data:/var/lib/headscale'
ports:
- 8081:8080
- 50443:50443
command: headscale serve
restart: unless-stopped
networks:
reverseproxy-nw:
headscale-ui:
image: ghcr.io/gurucomputing/headscale-ui:latest
restart: unless-stopped
container_name: headscale-ui
ports:
- 9443:443
networks:
reverseproxy-nw:
networks:
reverseproxy-nw:
external: true
volumes:
data:
driver: local
config:
driver: local
###############################################################################
wget https://github.com/juanfont/headscale/raw/main/config-example.yaml -O /root/headscale/config/config.yaml
# 下載完畢, 修改yaml檔案中以下參數
server_url: https://headscale.test.com
listen_addr: 0.0.0.0:8080
base_domain: test.com
#是否改寫用戶端dns,請自行測試, 依照需求決定
override_local_dns: true
# 提供(expose)給用戶端dns
nameservers:
- 1.1.1.1
- 8.8.4.4
# 公司內部專用網址,可分別參考不同dns
restricted_nameservers:
test.com:
- 192.168.1.1
# 停用magic dns
magic_dns: false
#其他如derp, 有機會再另外寫文章
cd /root/headscale
docker-compose up -d
<VirtualHost *:443>
ServerName headscale.test.com
ErrorLog /var/log/httpd/ssl_error_log
TransferLog /var/log/httpd/ssl_access_log
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/headscale.test.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/headscale.test.com/privkey.pem
SSLCACertificateFile /etc/letsencrypt//live/headscale.test.com/fullchain.pem
SSLProxyEngine On
ProxyPreserveHost On
Header add Access-Control-Allow-Origin "test.com";
SSLProxyCheckPeerName off
ProxyPass /web https://localhost:9443/web
ProxyPassReverse /web https://localhost:9443/web
ProxyPass / http://localhost:8081/ upgrade=any
ProxyPassReverse / http://localhost:8081/ upgrade=any
</VirtualHost>
https://headscale.test.com/windows
docker exec -it headscale headscale apikey create
# 建立使用者
# docker exec headscale headscale users create <使用者>
docker exec headscale headscale users create hlmtvpn
# 產生authkey, 讓tailscale端點使用
docker exec headscale headscale --user hlmtvpn preauthkeys create --reusable --expiration 24h
1. 列出 tailscale 端點
docker exec headscale headscale node list
2. 刪除 tailscale 端點
docker exec headscale headscale node delete -i <ID>
docker exec headscale headscale node delete -i 1
3. 列出 tailsacle 路由
docker exec headscale headscale route list
4. 啟用路由功能
docker exec headscale headscale route enable -r <ID>
5. 刪除路由表
docker exec headscale headscale route delete -r <ID> --force
公司架設tailscale 端點
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/jammy.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/jammy.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list
sudo apt-get update
sudo apt-get install tailscale
# http://headscale.test.com:8080是 headscale對外的URL
# d72e7351e24bbd21ecc99bbf5004c3e1f7cffa0631f8f5d5 是 authkey
# nat , 翻牆
tailscale up --reset --accept-routes --advertise-exit-node --snat-subnet-routes=true --accept-dns=false --advertise-routes=192.168.1.0/24 --login-server=https://headscale.test.com --authkey=d72e7351e24bbd21ecc99bbf5004c3e1f7cffa0631f8f5d5
# site to site , 不翻牆
tailscale up --reset --accept-routes --snat-subnet-routes=false --accept-dns=false --advertise-routes=192.168.1.0/24 --login-server=https://headscale.hlmt.com.tw --authkey=d72e7351e24bbd21ecc99bbf5004c3e1f7cffa0631f8f5d5
# 主機為vp, 不需要對外ip, 只要內網ip, 可上網, 要加上forward功能
# https://tailscale.com/kb/1019/subnets/
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf
#列出路由表
docker exec headscale headscale route list
#啟用路由
docker exec headscale headscale route enable -r <ID>
公司主要路由(router), 須額外設定靜態路由
若需要做到site to site
PC 用戶端安裝tailscale端點(可翻牆)
cd C:\Program Files\Tailscale
tailscale login --login-server https://headscale.test.com --exit-node=<headscale ip 可為headscale server local ip> --exit-node-allow-lan-access=true
此時網頁會出現一串指令, 請將該node key 給管理人員註冊
**這邊要注意的是網址指令裡面的 USERNAME , 是一開始 headscale 新增的使用者帳號.
# 管理人員到headscale主機註冊
docker exec headscale headscale nodes register --user hlmtvpn --key nodekey:32a95789aa71c2dc7ccfa43a16cf1cff575e318c0a67117370ec9c847ff76828
若管理人員註冊完成, PC上面的tailscale會自動登入, 代表註冊成功, 此時可以選擇變身成公司tailscale 端點(如下圖 william-standard-pc-i440fx-piix-1996) , 就可以以公司ip的名義上網翻牆, 當然也可也存取公司內網(tiptop erp不行).
Android
chrome宣稱預設語系是英文, 但這是唬爛的, 我們公司越南廠電腦安裝完畢, 預設語系一律自動變成越南文, 這對於IT來說很煩, 要改個設定什麼的, 都是折磨.
爬了文, 可以做成reg檔案, 直接執行就能強制修改預設語系, 終於解決這問題了.
複製以下文字,存成xxx.reg檔案, 再點選匯入即可, 台灣請將en改成 zh-TW , 或是按此下載做好的註冊檔案.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Policies\Google]
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Policies\Google\Chrome]
"ApplicationLocaleValue"="en"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Policies\Google\Chrome\ForcedLanguages]
"1"="en"
這是強制修改語系, 不能改回去, 若想讓麻瓜能自己再改回去, 請把上面 ForceLanguages 拿掉.
2017年寫了隻pdf附加保護的java程式, 給公司文管人員使用, 程式可離線使用,讓指定目錄裡面的pdf檔案, 批次一鍵上保全, 後來隨著人員異動漸漸失傳.
直到最近, 公司有新人需要這功能, 原因是部門沒有購買或租用 acrobat pdf編輯功能程式, adobe reader又不能上保全, 更不敢線上使用免費上保全網站, 因此我這個老程式又可以重出江湖了, 也改成 java 11使用.
源碼程式在這 https://github.com/WilliamFromTW/InMethodProtectPDF
可執行檔在這 https://github.com/WilliamFromTW/InMethodProtectPDF/releases
程式為runnable jar檔案 , 可以跨平台執行, 後來使用lunch4j這隻程式, 可以轉成windows可執行檔,很方便.
公司電子表單為鼎新的easyflow GP版, 需安裝支援java web start版本的java, 但我寫程式, 電腦只安裝java11, 不支援java web start怎辦? 我們可以下載IcedTea-Web , 安裝後就可以屎用了.
javaws xxx.jnlp
若出現unsigned jar 問題, 可以找到jdk或是jre , 修改conf\security\java.security這個檔案(安全風險請自行評估), 跳過安全驗證.
jdk.jar.disabledAlgorithms=MD2, RSA keySize < 1024, DSA keySize < 1024
這次出差越南, 遇到一個問題, 某台windows 10連到AD分享出來的folder, 但外包的電腦公司, 居然搞出該分享folder有sync center功能, 只為了讓使用者可以offline 做事, 但某天sync center同步功能壞了, 一樣是分享的fold, 怎樣也看不到別人異動過的.
我來處理問題時, 並不知道有做sync center, 這輩子也沒遇過”分享出來的目錄居然裡面內容跟別人不同“, 找了好久才發現是windows的sync center 搞鬼,於是我想辦法停用這功能, 但無能為力, google一些時間, 發現只要下這個指令, 重開機就可以解除該folder sync 功能.
#cmd run as administrator
REG ADD "HKLM\System\CurrentControlSet\Services\CSC\Parameters" /v FormatDatabase /t REG_DWORD /d 1 /f
我用過幾種GIT客戶端程式, 從tortoiseGit, GitEye, gitkraken,SourceTree,GitHub Desktop, 都長期用過, 但老實說我只用基本功能,因此看不出來差異在哪, 也不在意哪種用戶端程式好或不好.
直到最近,公司有個需求,要版控”機構部門的圖檔”,這原本是PLM宏大系統的功能(整合ERP,文件管制), 但…廠商報價後,就GG了.
於是我想自己找解決方案, 能滿足版控, 又要能滿足檔案鎖定功能, 也參考過網路力推,能管控圖檔的 https://www.perforce.com,
perforce 能版控,也能鎖檔案, 甚至細心列出git,svn,與自身產品的差異(當然是老王賣瓜了)
https://www.perforce.com/blog/vcs/git-vs-svn-what-difference
如果有預算, 我也建議圖檔管控應當要用perforce.
但我個人還是想要用git這個比較熟悉,簡單,無複雜系統的工具.
那問題來了,雖說git的LFS可以進行大檔案版本控管與鎖定,但客戶端工具程式還沒找到好用上手的,
直到SmartGit(20.1版以上)現世,這工具能針對檔案進行直覺的”鎖定”, 就好像用檔案總管一樣,能讓麻瓜容易上手.
雖說tortoiseGit也可以在客戶端就鎖定檔案,但整合度實在差太多了, 很不推薦.
不囉唆,寫心得
#執行cmd, 到專案Repository目錄執行
git lfs install
git lfs locks --local
git lfs locks --verify
## 設定那些檔案需要進行LFS管控
git lfs track *.exe --lockable
git lfs track *.zip --lockable
...
#修改.git\config 以下設定若沒有就自行新增
[lfs "https://server/repo.git/info/lfs"]
...
locksVerify = true
#"https://server/repo.git/info/lfs" 為 remote URL,加上/info/lfs
SmartGit->Edit->Preference->Low-level Properties
設定
status.lfs.locks = true
#也可以設定定期檢查其他人是否有鎖定檔案的時間(預設30分太久了)
backgroup.fetch.delay = 600
#改成每5分鐘查看一次
SmartGit->Edit->Preference->Backgroup Command->detect remote changes
設定
當專案Repository沒使用的時候, 或是已設定我的最愛的專案Repository 需要定期檢查LFS狀態
#若沒有設定,則不會自動更新狀態, 會無法得知其他人是否鎖定檔案
SmartGit 一套單機版最便宜約100美金左右
我以前文章「超簡單安裝collabora online」敘述如何讓nextcloud搭配online document server達到線上編輯功能 ; 後來發現Onlyoffice 更好用, 版面格式比較不會跑掉,就變心改用onlyoffice。
隨著公司越來越多人使用onlyoffice ,沒想到onlyoffice免費版有10人開啟檔案的上限,預算考量,只能另想辦法。
我回過頭來看collabora online , 雖是免費,但官方編譯一樣有20人數限制;照這樣子應該真的要去拍桌,跟老闆說要加錢購買onlyoffice。
可是偶然間發現有個群組, 協助編譯開源版collabora online,並且解除20人限制, 甚至編譯成 docker 版本, 真是佛心來的。
以下請參考github與docker網站:
https://github.com/tiredofit/docker-collabora-online
https://hub.docker.com/r/tiredofit/collabora-online/tags
官方文件很少。但不囉嗦, 我測試後直接寫如何安裝。
wget https://github.com/tiredofit/docker-collabora-online/raw/master/examples/docker-compose.yml
mv docker-compose.yml.traefik docker-compose.yml
vi docker-compose.yml
#改成醬
#紅色字需要修改
version: '3.7'
services:
collabora-online-app:
image: tiredofit/collabora-online:2.4.17
container_name: collabora-online-app
hostname: collabora-online.test.com
expose:
- 9980
ports:
- "9980:9980"
cap_add:
- MKNOD
- NET_ADMIN
privileged: true
labels:
- traefik.enable=true
- traefik.frontend.rule=Host:collabora-online.test.com
- traefik.port=9980
- traefik.protocol=http
- traefik.docker.network=proxy
- traefik.backend=collabora-online-app
volumes:
- ./logs:/logs
environment:
- CONTAINER_NAME=collabora-online-app
- ADMIN_USER=admin
- ADMIN_PASS=collabora-online
# 允許哪些網站存取
- ALLOWED_HOSTS=cloud.test.com,xxx.test.com
- ENABLE_TLS=FALSE
- ENABLE_TLS_REVERSE_PROXY=TRUE
restart: always
#2023/6/14
#2.4.17這版本pdf下載會出問題,因此更換2.4.34版,但是無法啟用成功,出現:
#ERROR: Cannot create container for service collabora-online-app: Conflict
#若要換新版本,需docker-compose down; docker rm collabora-online;
#修改yml檔案,改成新的版本號碼2.4.34後,再重新docker-compose up -d才能執行成功
<VirtualHost *:443>
ServerName collabora-online.test.com:443
# SSL configuration, you may want to take the easy route instead and use Lets Encrypt!
SSLCertificateFile /etc/letsencrypt/live/collabora-online.test.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/collabora-online.test.com/privkey.pem
SSLCACertificateFile /etc/letsencrypt/live/collabora-online.test.com/fullchain.pem
SSLProtocol all -SSLv2 -SSLv3
SSLEngine on
SSLHonorCipherOrder on
AllowEncodedSlashes NoDecode
ProxyPreserveHost On
# static html, js, images, etc. served from coolwsd
# browser is the client part of Collabora Online
ProxyPass /browser http://127.0.0.1:9980/browser retry=0
ProxyPassReverse /browser http://127.0.0.1:9980/browser
# WOPI discovery URL
ProxyPass /hosting/discovery http://127.0.0.1:9980/hosting/discovery retry=0
ProxyPassReverse /hosting/discovery http://127.0.0.1:9980/hosting/discovery
# Capabilities
ProxyPass /hosting/capabilities http://127.0.0.1:9980/hosting/capabilities retry=0
ProxyPassReverse /hosting/capabilities http://127.0.0.1:9980/hosting/capabilities
# Main websocket
ProxyPassMatch "/cool/(.*)/ws$" ws://127.0.0.1:9980/cool/$1/ws nocanon
# Admin Console websocket
ProxyPass /cool/adminws ws://127.0.0.1:9980/cool/adminws
# Download as, Fullscreen presentation and Image upload operations
ProxyPass /cool http://127.0.0.1:9980/cool
ProxyPassReverse /cool http://127.0.0.1:9980/cool
# Compatibility with integrations that use the /lool/convert-to endpoint
ProxyPass /lool http://127.0.0.1:9980/cool
ProxyPassReverse /lool http://127.0.0.1:9980/cool
</VirtualHost>
server { listen 443 ssl; server_name collaboraonline.example.com; ssl_certificate /path/to/certificate; ssl_certificate_key /path/to/key; # static files location ^~ /browser { proxy_pass http://127.0.0.1:9980; proxy_set_header Host $http_host; } # WOPI discovery URL location ^~ /hosting/discovery { proxy_pass http://127.0.0.1:9980; proxy_set_header Host $http_host; } # Capabilities location ^~ /hosting/capabilities { proxy_pass http://127.0.0.1:9980; proxy_set_header Host $http_host; } # main websocket location ~ ^/cool/(.*)/ws$ { proxy_pass http://127.0.0.1:9980; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $http_host; proxy_read_timeout 36000s; } # download, presentation and image upload location ~ ^/(c|l)ool { proxy_pass http://127.0.0.1:9980; proxy_set_header Host $http_host; } # Admin Console websocket location ^~ /cool/adminws { proxy_pass http://127.0.0.1:9980; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $http_host; proxy_read_timeout 36000s; } }
設定URL,以後開檔案將導入到 Collabora Online-server 達到線上作業功能
完成了
https://collabora-online.test.com/browser/dist/admin/admin.html
docker exec -it <容器名稱> bash
vi etc/coolwsd/coolwsd.xml
<remote_font_config>
<url desc="URL of optional JSON file that lists fonts to be included in Online" type="string" default="">https://cloud.test.com/apps/richdocuments/settings/fonts.json</url>
</remote_font_config>
另外要設定安全機制WOPI,一樣是修改 coolwsd,只允許相關ip才能存取
docker exec -it <容器名稱> bash
vi etc/coolwsd/coolwsd.xml
#########################################################
<alias_groups desc="xxxxxx" mode="groups">
<group><host desc="hostname to allow or deny." allow="true">192.168.1.1</host></group>
<group><host desc="hostname to allow or deny." allow="true">cloud.test.com</host></group>
</alias_groups>