發表文章

如何修復 PyCharm 的 "Cannot Save Settings: Please specify a different SDK name" 錯誤

圖片
 錯誤訊息: 解決步驟: 全部清除,再按 OK 再加上自己需要的版本後,就可以正常儲存。

關掉 RPi 的密碼登入功能

$ cd /etc/ssh $ nano sshd_config 加入以下三行 PasswordAuthentication no ChallengeResponseAuthentication no UsePAM no 存檔 重新啟動 ssh 服務 $  sudo systemctl restart ssh 最後你可以在 terminal 開另外一個 tab 來驗證是否成功: $  ssh pi@your-ip -o PubKeyAuthentication=no pi@your-ip: Permission denied (publickey).

RPi 作業系統的 ntp service 相關

查詢系統的自動同步時間服務 $ sudo systemctl status ntp.service  # 是否正常執行中 $ sudo systemctl stop ntp.service  # 停止 $ sudo systemctl start ntp.service  # 執行 $ sudo systemctl restart ntp.service  # 重新執行 $ sudo systemctl disable ntp.service  # 停用 $ sudo systemctl enable ntp.service  # 啟用 查詢 ntp 設定檔 $ cat /etc/ntp.conf # 使用 chronyd 的話 $ cat /etc/chrony/chrony.conf # 或是 $ less /etc/ntp.conf  # note: press q to exit 也可以使用以下命令直接查詢正在使用的 NTP 伺服器。這會向 NTP 伺服器發送查詢並顯示響應 $ ntpd -pdn # 使用 chronyd 的話 $ chronyc sources 修改 ntp 設定檔 $ sudo nano /etc/ntp.conf 加進多個 pool pool 1.tw.pool.ntp.org iburst pool 2.pool.ntp.org  iburst pool 0.tw.pool.ntp.org iburst pool 0.asia.pool.ntp.org iburst ntp service 路徑位置 $ sudo nano /lib/systemd/system/ntp.service 標案內容 [Unit] Description=Network Time Service Documentation=man:ntpd(8) After=network.target Conflicts=systemd-timesyncd.service [Service] Type=forking # Debian uses a shell wrapper to process /etc/default/ntp # and select DHCP-provided NTP servers if available ExecStart=/usr/li

如何設定crontab工作排程器 RPi

以 ntp 系統自動更新時間為相關例子 確認 crontab 服務正常 $ sudo systemctl status  crontab.service  # 是否正常執行中 $ sudo systemctl stop    crontab.service  # 停止 $ sudo systemctl start   crontab.service  # 執行 $ sudo systemctl restart crontab.service  # 重新執行 $ sudo systemctl disable crontab.service  # 停用 $ sudo systemctl enable  crontab.service  # 啟用 可以新增檔案放在 /etc/cron.d/ ,系統就會自動載入   $ sudo nano /etc/cron.d/auto_ntpdate 內容示意 */1 * * * * /bin/sh /home/pi/exec/whatevershell.sh > /dev/null 5 * * * *  root (/usr/sbin/ntpdate 118.163.81.63 )  &> /dev/null 10 * * * * root (/usr/sbin/ntpdate 162.159.200.1 )  &> /dev/null 15 * * * * root (/usr/sbin/ntpdate 17.253.116.253 ) &> /dev/null 20 * * * * root (/usr/sbin/ntpdate 103.147.22.149 ) &> /dev/null 25 * * * * root (/usr/sbin/ntpdate 211.22.103.157 ) &> /dev/null 30 * * * * root (/usr/sbin/ntpdate 140.112.2.188 )  &> /d

列出有在監聽的 port 指令

看有開的 port (listening ports) $ sudo netstat -tulpn $ sudo ss -tulpn $ sudo lsof -i -P -n | grep LISTEN
1. 在要連線的 client 端建立公鑰和私鑰 ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa.myskydevice -C "your_email@example.com" 2. 在 client 端 將公鑰添加到 server 端的授權鍵列表中:將 id_ rsa.myskydevice.pub 文件中的內容添加到目標用戶的 ~/.ssh/authorized_keys 文件中。如果該文件不存在,請創建它。 cat ~/.ssh/id_rsa.myskydevice.pub | ssh -i id_rsa.skydevice root@skydevice.local 'cat >> ~/.ssh/authorized_keys' 創建 authorized_keys touch ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys 3. 在 server 端設置文件和文件夾權限:請確保 ~/.ssh 文件夾的權限為 700,並且 authorized_keys 文件的權限為 600。 chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys 4. 在 server 端啟用 SSH 登入:確保您的 SSH 服務已啟用。如果您使用的是 Raspberry Pi,SSH 通常已經預先安裝並啟用。如果不確定,您可以通過運行以下命令來檢查: sudo systemctl status ssh 如果 SSH 服務未運行,您可以使用以下命令啟動它: sudo systemctl start ssh 5. 使用 nano 或 vi 查看和編輯 authorized_keys 文件:在您添加公鑰後,建議使用 nano 或 vi 來查看和編輯 ~/.ssh/authorized_keys 文件,以確保其中沒有任何亂碼或格式問題。 使用 nano 查看: nano ~/.ssh/authorized_keys 或者使用 vi 查看: vi ~/.ssh/authorized_keys