wslでnerves その7

# 概要
wsl(wsl2じゃない)でnervesやってみる。
qemu(x86_64エミュレータ、ラズパイじゃない)でやってみた。
練習問題やってみた。

# 練習問題
ssh接続せよ。

# 方針
wslのubuntuから、qemuにsshする。



# qemu起動手順

port 10022

```
"C:\Program Files\qemu\qemu-system-x86_64.exe" -drive file="hello_nerves.img",if=virtio,format=raw -net nic,model=virtio -net user,hostfwd=tcp::10022-:22,hostfwd=tcp::5300-:5300 -serial stdio
```

# ssh接続手順

```
$ ssh -p 10022 localhost
The authenticity of host '[localhost]:10022 ([127.0.0.1]:10022)' can't be established.
ED25519 key fingerprint is SHA256:Bh9x6IA3Jr6neN6VjaNCtvM7+F5EZRaVQRfIJPtSyNs.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:10022' (ED25519) to the list of known hosts.
Interactive Elixir (1.13.4) - press Ctrl+C to exit (type h() ENTER for help)
??????    ????
??  ??????  ??
??  ??  ??  ??   N  E  R  V  E  S
??  ??????  ??
????    ??????
hello_nerves 0.1.0 (b635da3d-e2de-5870-b878-d6d6630f4053) x86_64 x86_64
  Uptime       : 27 minutes and 5 seconds
  Clock        : 2023-01-14 22:25:02 UTC

  Firmware     : Valid (A)               Applications : 36 started
  Memory usage : 54 MB (48%)             Part usage   : 0 MB (0%)
  Hostname     : nerves-3456             Load average : 0.00 0.00 0.09

  eth0         : 10.0.2.15/24, fec0::5054:ff:fe12:3456/64, fe80::5054:ff:fe12:3456/64

Nerves CLI help: https://hexdocs.pm/nerves/iex-with-nerves.html

Toolshed imported. Run h(Toolshed) for more info.
iex(1)> :erlang.processes
[#PID<0.0.0>, #PID<0.1.0>, #PID<0.2.0>, #PID<0.3.0>, #PID<0.4.0>, #PID<0.5.0>,
 #PID<0.6.0>, #PID<0.7.0>, #PID<0.10.0>, #PID<0.877.0>, #PID<0.878.0>,
 #PID<0.880.0>, #PID<0.882.0>, #PID<0.883.0>, #PID<0.885.0>, #PID<0.886.0>,
 #PID<0.887.0>, #PID<0.889.0>, #PID<0.890.0>, #PID<0.891.0>, #PID<0.892.0>,
 #PID<0.893.0>, #PID<0.894.0>, #PID<0.895.0>, #PID<0.896.0>, #PID<0.897.0>,
 #PID<0.898.0>, #PID<0.899.0>, #PID<0.900.0>, #PID<0.901.0>, #PID<0.902.0>,
 #PID<0.903.0>, #PID<0.904.0>, #PID<0.905.0>, #PID<0.906.0>, #PID<0.911.0>,
 #PID<0.912.0>, #PID<0.913.0>, #PID<0.917.0>, #PID<0.918.0>, #PID<0.922.0>,
 #PID<0.926.0>, #PID<0.927.0>, #PID<0.928.0>, #PID<0.929.0>, #PID<0.930.0>,
 #PID<0.932.0>, #PID<0.933.0>, #PID<0.934.0>, #PID<0.935.0>, ...]
iex(2)> |> length
160
iex(3)> Application.loaded_applications()
[
  {:crypto, 'CRYPTO', '5.1.2'},
  {:public_key, 'Public key infrastructure', '1.13.2'},
  {:vintage_net_direct, 'Direct Ethernet networking for VintageNet', '0.10.6'},
  {:shoehorn, 'Shoehorn helps you handle OTP application failures', '0.9.1'},
  {:logger, 'logger', '1.13.4'},
  {:beam_notify, 'Send a message to the BEAM from a shell script', '1.0.0'},
  {:gen_state_machine, 'An Elixir wrapper for gen_statem.', '3.0.0'},
  {:elixir, 'elixir', '1.13.4'},
  {:property_table, 'In-memory key-value store with subscriptions', '0.2.2'},
  {:kernel, 'ERTS  CXC 138 10', '8.5.2'},
  {:nerves_runtime, 'Small, general runtime utilities for Nerves devices',
   '0.13.3'},
  {:vintage_net, 'Network configuration and management for Nerves', '0.12.2'},
  {:iex, 'iex', '1.13.4'},
  {:stdlib, 'ERTS  CXC 138 10', '4.2'},
  {:runtime_tools, 'RUNTIME_TOOLS', '1.19'},
  {:circular_buffer, 'General purpose circular buffer.\n', '0.4.1'},
  {:sasl, 'SASL  CXC 138 11', '4.2'},
  {:ring_logger, 'A ring buffer backend for Elixir Logger with IO streaming',
   '0.8.6'},
  {:nerves_motd, 'Message of the day for Nerves devices', '0.1.9'},
  {:ssh_subsystem_fwup,
   'Over-the-air updates to Nerves devices via an ssh subsystem', '0.6.1'},
  {:nerves_logging, 'Route system log messages through the Elixir logger',
   '0.2.0'},
  {:uboot_env, 'Read and write to U-Boot environment blocks', '1.0.1'},
  {:toolshed, 'Use Toolshed for path completion and more helpers for IEx',
   '0.2.26'},
  {:vintage_net_wifi, 'WiFi networking for VintageNet', '0.11.1'},
  {:muontrap, 'Keep your ports contained', '1.1.0'},
  {:asn1, 'The Erlang ASN1 compiler version 5.0.21', '5.0.21'},
  {:nerves_time, 'Keep time in sync on Nerves devices', '0.4.5'},
  {:vintage_net_ethernet, 'Ethernet networking for VintageNet', '0.11.0'},
  {:nerves_uevent,
   'Simple UEvent monitor for detecting hardware and automatically loading drivers',
   '0.1.0'},
  {:mdns_lite, 'A simple, no frills mDNS implementation in Elixir', '0.8.6'},
  {:nerves_pack, 'Initialization setup for Nerves devices', '0.7.0'},
  {:compiler, 'ERTS  CXC 138 10', '8.2.2'},
  {:ssh, 'SSH-2 for Erlang/OTP', '4.15.1'},
  {:one_dhcpd, 'One address DHCP server', '2.0.1'},
  {:hello_nerves, 'hello_nerves', '0.1.0'},
  {:nerves_ssh, 'Manage a SSH daemon and subsystems on Nerves devices', '0.4.1'}
]
iex(4)> Application.get_all_env(:ex)
[]
iex(5)> 



```

以上。