1. 程式人生 > >Windows遠端連線樹莓派

Windows遠端連線樹莓派

SSH

使用Windows上的Linux子系統通過ssh連線樹莓派。

  1. 安裝expect
    sudo apt-get install tcl tk expect
  2. 寫登陸指令碼
    '''

    cd
    touch connect_to_pi.sh
    chmod +x connect_to_pi.sh
    vim connect_to_pi.sh
    // 以下為文字內容                            
    #! /usr/bin/expect
    set timeout 3
    set host "192.168.11.104"    // your raspberrypi ip
    set username "pi"            // your username
    set password "raspberrypi"   // your password
    set timeout 10
    
    spawn ssh 
    [email protected]
    $host expect "*password*" {send "$password\r"} interact // 文字結束 :wq

    '''

  3. 使用指令碼登陸
    '''

    cd
    ./connect_to_pi.sh

    '''

  4. 使用命令別名執行指令碼
    '''

    cd
    vim .bashrc
    // 檔案中新增下一行
    alias sshpi="/home/xiaohei/connect_to_pi.sh" // 改為自己的使用者
    :wq
    source .bashrc

    '''

遠端圖形桌面

使用Windows遠端桌面連線樹莓派

  1. 樹莓派上安裝xrdp
  2. 遠端桌面