We are going to access our target system via the network. QEMU provides a virtual network interface for the emulated machine, and we can use it without connecting to a real network. In order to do so, we need to figure out an IP address to use and make sure that the SSH server is running in our virtual environment:
In your native operating system environment, work out the IP address of your machine. Open a Terminal window or PowerShell. Run ifconfig on macOS, or Linux, or ipconfig for Windows, and check its output.
In the next steps, we will use 192.168.1.5 as a template IP address; you will need to replace it with your actual IP address.
- Switch to the Raspberry Pi emulator and enable SSH services by running the following command:
$ sudo systemctl start ssh
- Switch to the Ubuntu window and install the SSH client:
# apt install -y ssh
- Now, we can copy the hello executable to the target system:
# scp -P22023 /mnt/hello [email protected]:~
- When asked for a password, type raspberry. Switch back to the Raspberry Pi emulator window. Check that the executable we just copied is there:
$ ls hello
hello
- Now, run the program:
$ ./hello
As we can see, the program is now running as expected.