LoginSignup
0
0

More than 1 year has passed since last update.

USB接続されたRaspberry Pi Zeroに、Virtual BoxのUbuntu経由でWindowsからSSH・VNC接続する方法

Last updated at Posted at 2021-10-30

自分の環境では、どうしてもWindowsからRaspberry Pi Zero(以下、RPi)にUSB接続(USB Ethernet)できなかったので、Windows上のVirtual Box(以下、VBox)でUbuntuを起動して、これを経由してWindowsからRPiにVNC接続するまでをまとめました。

20211104続報

↓ VBoxのUbuntuでも見えなくなりました。その後、Imagerの際にホスト名を変更したらアクセスできました。ネームとしての識別性が重要なのか。また続報します。

手順

  1. 上記URLを参考にmicroSD(RPi OS)ドライブ内のconfig.txt、cmdline.txtを編集、sshという空ファイルを作成
    1. RPiをPCにUSB接続 ← PC環境はWindows+VBox(Ubuntu)
  2. VBoxでUbuntuを起動
    1. VBoxのメニュータブから「デバイス → USB → Linux ... Ethernet Gadget」をチェック
    2. Ubuntuターミナルでifconfigを実行 ← USB Ethernetのinterfaceが加わっている。例えば、enxb662d8c332e8
  3. それを用いて、以下のコマンドを順次実行(上記URLを参照)
$ nmcli c add type ethernet con-name raspi-usb ifname enxb662d8c332e8
$ nmcli c modify raspi-usb ipv4.method shared
$ nmcli c up raspi-usb
  • これでUSB Ethernetが正常に接続するはず ← Ubuntu側(上記interface)に10.42.0.1みたいなIPが振られる
    1. まずは ssh pi@raspberrypi.localでログイン(←このように名付けていれば)
    2. ログイン後、RPi側でifconfigでIPを調べる → 例えば、10.42.0.151
  • 後は、仮にVBox UbuntuのIP(ホストオンリーネットワーク)が192.168.56.101となっているとして、Windowsのcmdから以下のトンネルを掘る
    1. ssh -L 5900:10.42.0.151:5900 username@192.168.56.101 ← VNCを5900ポート運用として
    2. これでWindowslocalhost:5900からVNC経由でRPiに接続できる
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0