Linux: May 2016 Archives

XML formating

user-pic
Vote 0 Votes

| xmllint --format - # need libxml2 package
| xmlstarlet fo # need xmlstarlet
Make it more readable.

JSON formating

user-pic
Vote 0 Votes

| python -m json.tool # need python package
| jq . # need jq package
Make it more readable.

nginx+PHP

user-pic
Vote 0 Votes

nginx (發音 engine) 近幾年因為性能卓越, 市佔已愈來愈高, 僅次於 Apache, IIS, 排第三
官方有提供 Prebuilt Packages, 安裝很方便
Create /etc/yum.repos.d/nginx.repo

yum -y install nginx

PHP 在 configure 需加 --enable-fpm 參數
設定檔用預設的即可 cp sapi/fpm/php-fpm.conf /usr/local/etc/php-fpm.conf
執行 php-fpm 會 Listen 9000 Port
nginx 設定檔 /etc/nginx/conf.d/default.conf
這是 HTTP + HTTPS + PHP 的典型設定, DocumentRoot 在 /var/www/html
若 SSL 憑證是用 Let's Encrypt, ssl_certificate 這個參數要把這兩個檔合併 cert.pem, chain.pem
cat cert.pem chain.pem > cert_chain.pem
若只有 cert.pem 的內容, 試過一般瀏覽器可以正常, 但是 curl, wget, links, lynx, w3m 等 CLI 工具都會出現錯誤
curl: (60) Peer certificate cannot be authenticated with known CA certificates
wget: ERROR: The certificate of 'yourhost.com' is not trusted.
links: SSL error
lynx: SSL error:unable to get local issuer certificate
w3m: unable to get local issuer certificate
ERROR: The certificate of 'yourhost.com' hasn't got a known issuer.

ref. Install NGINX

openssl s_client

user-pic
Vote 0 Votes

openssl s_client 可用來查看 HTTPS Server 的憑證
openssl s_client -connect helloworld.letsencrypt.org:443
or
openssl s_client -host helloworld.letsencrypt.org -port 443

ssh user@host bash -s -- < local-script.sh

You can add arguments if you need.
ssh user@host bash -s -- < local-script.sh argv1

sshpass

user-pic
Vote 0 Votes

一般是建 Key 來達成 ssh 免密碼, 若不想建 Key, 可以用 sshpass
sshpass 可以在 ssh 時自動將密碼帶入
密碼可以用檔案(-f filename)或參數(-p password)或變數SSHPASS(-e)帶入
e.g.
sshpass -f pass_file ssh user@somewhere.com
sshpass -p password ssh user@somewhere.com
export SSHPASS=password
sshpass -e user@somewhere.com
當然也可以直接執行所連線主機的 command
sshpass -e user@somewhere.com cat /etc/hosts

About this Archive

This page is an archive of entries in the Linux category from May 2016.

Linux: January 2016 is the previous archive.

Linux: June 2016 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Linux: Monthly Archives

Monthly Archives