2019年2月20日 星期三

dd

dd

dd用得到的指令

寫一個指定大小的空檔案

dd if=/dev/zero of=dd_1G bs=1M count=1024

寫入映像檔至隨身碟

dd if=<imgfile> -of=</dev/sd...>

2019年2月17日 星期日

firewalld

firewalld

一些firewalld的筆記

新增service

新增指定service
firewall-cmd --zone=\<zone name> --add-service=\<service name>

列出service
firewall-cmd --get-services

自訂service
/etc/firewalld/services/下新增\<service name>.xml檔,格式參考/usr/lib/firewalld/services/下的檔案
並執行
firewall-cmd --reload後就可以用--get-services參數看到該service

新增允許連入的IP

暫時
firewall-cmd --zone=public --add-rich-rule 'rule family="ipv4" source address="192.168.0.0/24" service name="http" accept'
永久
firewall-cmd --zone=public --add-rich-rule 'rule family="ipv4" source address="192.168.0.0/24" service name="http" accept'--permanent

Ref

https://blog.gtwang.org/linux/centos-7-firewalld-command-setup-tutorial/2/

2019年2月10日 星期日

dmlite-shell

dmlite-shell

dmlite-shell

這篇筆記中記錄了一些關於dmlite-shell的使用方式

dmlite-shell -e 'command’
-e 參數可以在外部直接執行dmlite-shell的指令,如此便能用python或bash來批次執行指令

2019年2月3日 星期日

openssl

openssl

openssl 常用的指令

X509

X509證書中包含了許多資訊,例如頒發者(Issuer)、主題(Subject)、起始時間(notBefore)、結束時間(notAfter)以及公鑰。這些資訊可以用openssl指令擷取出來,這篇筆記中記錄了一些最近常用的指令。

擷取頒發者資訊

openssl x509 -in <x509 cert file> -noout -issuer

擷取主題資訊

openssl x509 -in usercert.pem -noout -subject

印出證書相關訊息

openssl x509 -in usercert.pem -noout -text

pkcs 12

pkcs 12是種文件格式,副檔名為.p12,內部能包入多個加密對象,設計上具有相當多種功能,實際上大多只用來打包私鑰以及x509證書。在目前的工作中,常使用的功能如下:

輸出pkcs 12文件中的私鑰及證書

openssl pkcs12 -clcerts -nodes -in <filename>.p12 -out clkey.pem
-clcerts:輸出client的資訊
-nodes:不對私鑰進行加密(不加上此參數的話,要輸入密碼)

輸出pkcs 12文件中的私鑰

openssl pkcs12 -nocerts -clcerts -nodes -in <filename>.p12 -out clkey.pem
-nocerts:不要輸出證書

輸出pkcs 12文件中的證書

openssl pkcs12 -nokeys -clcerts -in CERN.p12 -out clcert.pem
-nokeys:別輸出私鑰

檢查

openssl verify -verbose -CAfile trustedca.pem usercert.pem

-CAfile檔案中必須含有信任鍊中的每個證書,以CERN CA為[4]例,把CERN Root Certification Authority 2.crtCERN Root Certification Authority 2.crt兩個檔案相結合即是合法的*-CAfile*

另外,也可以使用這種方式
openssl verify -verbose -CAfile CERN-Root-2.pem -untrusted CERN-GridCA.pem ~/testcert.pem
兩種做法看起來是等價的

ref

[1] openssl manpage
[2] x509 manpage
[3] pkcs12 manpage
[4] CERN CA

Written with StackEdit.