在Debian系統上使用OpenSSL進行遠程連接通常涉及以下步驟:
生成證書和密鑰:
配置OpenSSL服務器:
/etc/ssl/openssl.cnf
),設置服務器證書、私鑰和其他相關選項。配置防火墻:
啟動OpenSSL服務器:
客戶端配置:
具體步驟如下:
# 生成私鑰
openssl genpkey -algorithm RSA -out server.key -aes256
# 生成證書簽名請求(CSR)
openssl req -new -key server.key -out server.csr
# 生成自簽名證書
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
編輯/etc/ssl/openssl.cnf
文件,確保以下配置項正確:
[ req ]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn
x509_extensions = x509_ext
[ dn ]
C=US
ST=State
L=City
O=Organization
OU=Organizational Unit
CN=example.com
[ x509_ext ]
subjectAltName = @alt_names
[ alt_names ]
DNS.1 = example.com
DNS.2 = www.example.com
確保防火墻允許端口443的流量:
sudo ufw allow 443/tcp
使用以下命令啟動OpenSSL服務器:
openssl s_server -www -cert server.crt -key server.key -port 443
客戶端需要信任服務器的證書??梢詫⒎掌鞯淖C書添加到客戶端的受信任證書存儲中,或者使用自簽名證書進行測試。
添加證書到受信任存儲(以Debian為例):
sudo cp server.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
使用自簽名證書進行測試: 客戶端可以使用以下命令連接到服務器并驗證證書:
openssl s_client -connect example.com:443 -CAfile server.crt
通過以上步驟,你可以在Debian系統上使用OpenSSL進行遠程訪問控制。確保在生產環境中使用受信任的證書頒發機構簽發的證書,以保證通信的安全性。