顯示具有 systemctl 標籤的文章。 顯示所有文章
顯示具有 systemctl 標籤的文章。 顯示所有文章

2026/01/27

現在只要開ftp就會被弱掃列入中風險
但又因為某些原因沒辦法全部使用ssh
所以改用ftps
步驟如下

先建立一支私憑証

openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem

更改權限 不讓其他人讀取

chmod 600 /etc/ssl/private/vsftpd.pem

修改/etc/vsftpd/vsftpd.conf 在最後加上

# 啟用 SSL
ssl_enable=YES

# 指定剛產生的 .pem 檔案路徑
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem

# 其他加密設定
force_local_data_ssl=YES
force_local_logins_ssl=YES

重新啟動 vsftpd

systemctl restart vsftpd

2025/06/19

為了解決近期弱掃出現的portmapper 中風險
決定把 rpcbind 關了
之後nfs全部走4版

systemctl disable rpcbind.socket
systemctl disable rpcbind.service

mount -t nfs4


2025/01/14

又到了弱掃的時間
昨天看報告
有二個問題

Vulnerability Detection Result
The remote SSH server supports the following weak KEX algorithm(s):
KEX algorithm | Reason
------------------------------------------------
diffie-hellman-group-exchange-sha1 | Using SHA-1


Vulnerability Detection Result
The remote SSH server supports the following weak client-to-server encryption algorithm(s):
aes128-cbc
aes256-cbc
The remote SSH server supports the following weak server-to-client encryption algorithm(s):
aes128-cbc
aes256-cbc


想說改一下 /etc/ssh/sshd_config就可以了

Ciphers aes128-ctr,aes192-ctr,aes256-ctr

KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512

沒想到重掃還是一樣

因為每次掃都要花很多時間
所以使用 nmap 特別針對ssh server來掃

nmap --script ssh2-enum-algos -sV -p 22   10.0.0.1


Starting Nmap 7.80 ( https://nmap.org ) at 2025-01-21 13:47 CST
Nmap scan report for 10.0.0.1
Host is up (0.00079s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.0 (protocol 2.0)
| ssh2-enum-algos: 
|   kex_algorithms: (12)
|       curve25519-sha256
|       curve25519-sha256@libssh.org
|       ecdh-sha2-nistp256
|       ecdh-sha2-nistp384
|       ecdh-sha2-nistp521
|       diffie-hellman-group-exchange-sha256
|       diffie-hellman-group14-sha256
|       diffie-hellman-group16-sha512
|       diffie-hellman-group18-sha512
|       diffie-hellman-group-exchange-sha1
|       diffie-hellman-group14-sha1
|       kex-strict-s-v00@openssh.com
|   server_host_key_algorithms: (5)
|       rsa-sha2-512
|       rsa-sha2-256
|       ssh-rsa
|       ecdsa-sha2-nistp256
|       ssh-ed25519
|   encryption_algorithms: (7)
|       aes256-gcm@openssh.com
|       chacha20-poly1305@openssh.com
|       aes256-ctr
|       aes256-cbc
|       aes128-gcm@openssh.com
|       aes128-ctr
|       aes128-cbc
|   mac_algorithms: (8)
|       hmac-sha2-256-etm@openssh.com
|       hmac-sha1-etm@openssh.com
|       umac-128-etm@openssh.com
|       hmac-sha2-512-etm@openssh.com
|       hmac-sha2-256
|       hmac-sha1
|       umac-128@openssh.com
|       hmac-sha2-512
|   compression_algorithms: (2)
|       none
|_      zlib@openssh.com

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 0.29 seconds

果然還是沒用
找了半天資料 才找到解決方法

先處理 
aes128-cbc
aes256-cbc

先建一個文件內容如下

vi /etc/crypto-policies/policies/modules/DISABLE-CBC.pmod

cipher = -AES-128-CBC -AES-256-CBC
ssh_cipher = -AES-128-CBC -AES-256-CBC


更新加密策略

update-crypto-policies --set DEFAULT:DISABLE-CBC


再來處理

diffie-hellman-group-exchange-sha1


vi /etc/crypto-policies/back-ends/opensshserver.config

刪除以下文字

,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1



重啟 sshd

systemctl restart sshd


再跑一次 
nmap --script ssh2-enum-algos -sV -p 22   10.0.0.1

Starting Nmap 7.80 ( https://nmap.org ) at 2025-01-21 13:59 CST
Nmap scan report for 10.0.0.1
Host is up (0.00077s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.0 (protocol 2.0)
| ssh2-enum-algos: 
|   kex_algorithms: (10)
|       curve25519-sha256
|       curve25519-sha256@libssh.org
|       ecdh-sha2-nistp256
|       ecdh-sha2-nistp384
|       ecdh-sha2-nistp521
|       diffie-hellman-group-exchange-sha256
|       diffie-hellman-group14-sha256
|       diffie-hellman-group16-sha512
|       diffie-hellman-group18-sha512
|       kex-strict-s-v00@openssh.com
|   server_host_key_algorithms: (5)
|       rsa-sha2-512
|       rsa-sha2-256
|       ssh-rsa
|       ecdsa-sha2-nistp256
|       ssh-ed25519
|   encryption_algorithms: (5)
|       aes256-gcm@openssh.com
|       chacha20-poly1305@openssh.com
|       aes256-ctr
|       aes128-gcm@openssh.com
|       aes128-ctr
|   mac_algorithms: (8)
|       hmac-sha2-256-etm@openssh.com
|       hmac-sha1-etm@openssh.com
|       umac-128-etm@openssh.com
|       hmac-sha2-512-etm@openssh.com
|       hmac-sha2-256
|       hmac-sha1
|       umac-128@openssh.com
|       hmac-sha2-512
|   compression_algorithms: (2)
|       none
|_      zlib@openssh.com

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 0.33 seconds


已經全部修正
再重掃一次也沒問題了

2024/11/27

記一下在 almalinux 9 上安裝docker後再安裝n8n docker

先裝 docker

dnf install 'dnf-command(config-manager)'

dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

dnf install docker-ce docker-ce-cli containerd.io

裝好後設定docker 的 daemon

systemctl start docker
systemctl enable docker


接下來安裝 n8n

先建立放資料的 volume

docker volume create n8n_data

docker pull docker.n8n.io/n8nio/n8n


# Start docker 有些參數要加  以下方為準    官方說明太簡單

docker run -it --name n8n -p 5678:5678 --restart=always -e GENERIC_TIMEZONE="Asia/Taipei" -e TZ="Asia/Taipei" -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true -e N8N_SECURE_COOKIE=false -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n

如果這裡timezone 沒設 每次新建 workflow的時候都要再改 有點煩 而且很容易忘記

再來就可以開browser登入了 http://10.0.0.1:5678


以下步驟是n8n docker 有新版本的更新方式 

docker pull docker.n8n.io/n8nio/n8n

# Get the container ID
docker ps -a

# Stop the container with ID container_id
docker stop [container_id]

# Remove the container with ID container_id
docker rm [container_id]

# Start the container
docker run -it --name n8n -p 5678:5678 --restart=always -e GENERIC_TIMEZONE="Asia/Taipei" -e TZ="Asia/Taipei" -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true -e N8N_SECURE_COOKIE=false -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n

#remove unused image
docker image prune


2019/10/21

proxmox mail gateway

預設不會去記錄信件主旨
因此要查找的時候有些不方便
修改方法如下

在 /etc/postfix/main.cf最後增加一行如下

header_checks = regexp:/etc/postfix/header_checks

建立 /etc/postfix/header_checks 這個檔 內容如下

/^Subject:/      WARN

接下來重啟服務
systemctl restart postfix

之後就可以在 /var/log/mail.log看到如下的log

Oct 21 06:43:49 mg postfix/cleanup[19866]: 74A29109C: warning: header Subject: Congratulate Jimmy (Gin-der) Peng for... from mailc-ab.linkedin.com[108.174.3.162]; from=<s-2f4oc1y30l5mpjzdxdjdkon8civu58akgxu9lf1h23ha66tmdhfi46d4@bounce.linkedin.com> to=<abc@de.com> proto=ESMTP helo=<mailc-ab.linkedin.com>

以上的方法在几器重開後 config就會被改回來

找到另一個方法
直接去改pmg的perl

First, add this somewhere between the 'use' statements at the beginning of the file:

use PVE::Tools;

Then search for this line:

$self->log (3, "$queue->{logid}: new mail message-id=%s", $queue->{msgid});

Add the following below that line:

$self->log (3, "$queue->{logid}: Subject: %s", PMG::Utils::decode_rfc1522(PVE::Tools::trim($entity->head->get('subject'))) || 'No Subject');
my @fromarray = split('\s*,\s*', $entity->head->get('from') || $msginfo->{sender});
$self->log (3, "$queue->{logid}: From: %s", PMG::Utils::decode_rfc1522(PVE::Tools::trim($fromarray[0])) );

https://forum.proxmox.com/threads/how-to-log-subjects-of-all-incoming-email.54191/

第二種方法會把subject放在獨立行
不方便查找

官方其實有提供解法方法

You can find the default templates in /var/lib/pmg/templates/. Please do not modify them directly, because your modification would get lost on the next update. Instead, copy the template you wish to change to /etc/pmg/templates/, then apply your changes there.

Templates can access any configuration setting, and you can use the pmgconfig dump command to get a list of all variable names:

# pmgconfig dump
...
dns.domain = yourdomain.tld
dns.hostname = pmg
ipconfig.int_ip = 192.168.2.127
pmg.admin.advfilter = 1
...
The same tool is used to force regeneration of all template based configuration files. You need to run that after modifying a template, or when you directly edit configuration files

# pmgconfig sync --restart 1

https://pmg.proxmox.com/pmg-docs/pmg-admin-guide.html#_service_configuration_templates

2017/05/04

這几天在設定openvpn的時候發生一個鳥問題
用rpm安裝好後手動執行
/usr/sbin/openvpn --config /etc/openvpn/client/client.conf
程式可以啟動 正常運作沒問題
但因為需要開机啟動
沒想到執行
systemctl start openvpn-client@.service
一直出現錯誤
無法執行
想說好吧
那就加在 /etc/rc.local好了
沒想到竟然也不行
XD
最後搞了半天
只有加在crontab才有用

@reboot cd /root;./vpn_start


2016/02/17

debian安裝後若不使用nfs
可以把二個service 關了

systemctl disable nfs-common
systemctl disable rpcbind

2016/02/15

今天本來是要升級OCS
但升到2.2後畫面竟然只有几個數字
而且升級的過程一直不順
想說重裝好了
因為原來是裝在centos 5上
而centos 5 的EOL是2017年3 月
所以試看看裝在centos 7 會不會比較沒問題
查了一下
現在在centos 7 上裝很簡單了
稍微記錄一下
最小安裝後改一下hosts.allow hosts.deny 及selinux
關掉filewalld
systemctl stop firewalld
systemctl disable firewalld

再裝一下net-tools及 epel-release
epel-release是用來加入額外repo
安裝mariadb
yum install mariadb-server -y
systemctl start mariadb
systemctl enable mariadb

修改mariadb的root密碼及一些安全設定
mysql_secure_installation

再來安裝ocs
yum install -y ocsinventory-server ocsinventory-reports

因為加入了epel-release 所以系統會把所有相依性的套件一次裝好

啟動httpd服務
systemctl start httpd
sytemctl enable httpd

接下來就可以進入web介面 依畫面指示進行接下來的安裝動作了
http://ocs-server-ip/ocsreports/

預設登入帳號密碼是 admin/admin 記得要改

修改server ip 使用文字化圖形介面指令
nmtui

目前的版本是2.1.2
再等一陣子看看 應該會直接升到 2.2 到時直接使用yum update就好了

2016/01/11

昨天看到這個工具還不錯 fastnetmon
https://github.com/pavel-odintsov/fastnetmon
可以使用netflow sflow port mirror的資料來計算pps mbps 及flow數
當到達指定的上限時
可以發出告警或執行特定動作
安裝很簡單
裝好centos 7後

wget https://raw.githubusercontent.com/pavel-odintsov/fastnetmon/master/src/fastnetmon_install.pl -Ofastnetmon_install.pl

perl fastnetmon_install.pl

會自動把需要的套件補齊
裝好後依需求修改 /etc/fastnetmon.conf
另外在/tmp找到notify_about_attack.sh
cp到/usr/local/bin/ 一樣依需求修改內容

如果使用port mirror 要把網卡的 promisc打開
寫入 /etc/rc.local
/usr/sbin/ifconfig eth1 promisc

再來設定開机執行 fastnetmon

systemctl enable fastnetmon

以下的程式可以觀看即時的狀況
/opt/fastnetmon/fastnetmon_client