樹莓派安裝SSH


1. 安裝ssh

 sudo apt-get install openssh-server 

2. 檢查樹莓派SSH服務是否開啟

 ps -e|grep ssh 

3. SSH服務開啟

 sudo /etc/init.d/ssh start 

4. 在樹莓派終端輸入(臨時的,重啟失效):

sudo service ssh start
sudo service ssh status

如果ssh運行會打印如下類似信息:

ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-06-17 17:17:04 CST; 20h ago
  Process: 403 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 439 (sshd)
   CGroup: /system.slice/ssh.service
           └─439 /usr/sbin/sshd -D

Jun 18 13:37:50 raspberrypi sshd[21733]: Accepted password for pi from 192.168.169.151 port 2805 ssh2
Jun 18 13:37:50 raspberrypi sshd[21733]: pam_unix(sshd:session): session opened for user pi by (uid=0)
Jun 18 14:09:45 raspberrypi sshd[30043]: Accepted password for pi from 192.168.169.151 port 10399 ssh2
Jun 18 14:09:45 raspberrypi sshd[30043]: pam_unix(sshd:session): session opened for user pi by (uid=0)
Jun 18 14:13:16 raspberrypi sshd[31028]: Accepted password for pi from 192.168.169.203 port 52093 ssh2
Jun 18 14:13:16 raspberrypi sshd[31028]: pam_unix(sshd:session): session opened for user pi by (uid=0)
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

5. 樹莓派SSH服務開機自動啟動

在終端命令行中啟動SSH服務后,如果系統重啟或關機后啟動,SSH服務默認是關閉的,依然需要手動啟動,為了方便可以設置SSH服務開機自動啟動,打開 /etc/rc.local 文件,在語句 exit 0 之前加入:

 /etc/init.d/ssh start 

6.其他方式開啟SSH

  1. 通過 sudo raspi-config 通過可視化界面開啟SSH.
  2. 在SD開根目錄創建SSH文件,開啟SSH.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM