Serenity Operating System
1# Transferring files from QEMU to your host machine
2
3## Method 1: WebServer
4Serenity has a built-in web server which extends to your host machine.
5
6Open a new terminal and use the following command to start a WebServer instance for the current working directory:
7
8```console
9ws .
10```
11
12Then we just open `localhost:8000` on our host machine :^)
13
14
15
16**NOTE:** Due to the fact that some browsers download unrecognized files as plain text, you may want to use something like `wget` to download the file **as is** instead. Otherwise the file may appear corrupted when the system tries to load it.
17
18## Method 2: Mount the disk image
19
20Another way is to mount Serenity's `_disk_image` to your host machine by using the following command on *nix systems (or inside WSL):
21
22```console
23cd "Build/${SERENITY_ARCH}"
24mkdir mnt
25sudo mount -t ext2 _disk_image mnt
26```
27
28## Method 3: Archiving tool with ext2 support
29
30Some archiving tools, like [7-Zip](https://www.7-zip.org/), are capable of directly opening ext2 images like Serenity's `_disk_image`. With these, you can open the disk image like any other archive and extract the files you need.
31
32For WSL users: If you have the image on your native WSL drive (recommended), this drive can be opened in Explorer by manually opening `\\wsl$` (not visible in the Network tab!) and then the "network share" corresponding to your distro.
33
34## Method 4: Enable OpenSSH on host and use sftp client on SerenityOS
35
36- Setup OpenSSH server on your host.
37For windows: Google is your friend (https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse)
38For linux: Google is your friend.
39- Ensure that you already have a working SerenityOS working build.
40```console
41$ Meta/serenity.sh rebuild-world
42```
43- To enable OpenSSH package from SerenityOS: (initial directory is SerenityOS ROOT_DIR)
44
45```console
46cd Ports
47cd openssh
48./package.sh
49cd ../..
50Meta/serenity.sh run
51```
52- From within SerenityOS, check that you have a working sftp app:
53
54```console
55courage:~ $ sftp
56```
57The expected response will be:
58
59```console
60courage:~ $ sftp
61usage: sftp [-46aCfNpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
62 [-D sftp_server_path] [-F ssh_config] [-i identity_file]
63 [-J destination] [-l limit] [-o ssh_option] [-P port]
64 [-R num_requests] [-S program] [-s subsystem | sftp_server]
65 destination
66```
67- Assume that you have a working OpenSSH server as mentioned earlier, with an IP address of 192.168.0.11.
68- Assume that you have a valid user on that host with account name user1.
69- Assume that you are currently inside the folder from which you want to transfer the file(s) from.
70- Local
71 User: anon
72- Remote
73 User: user1
74 IP Address: 192.168.0.11
75- Connect to remote server via sftp
76
77```console
78courage:~ $ sftp user1@192.168.0.11
79The authenticity of host '(192.168.0.11)' can't be established.
80ECDSA key finger print is SHA256:Iav!m/E0cHJBnzSk0hJEZnBZ2F3LBL4wxhyv4nrfPtU.
81Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
82
83user1@'s password:
84Connected to 192.168.0.11
85
86```
87- By this time, you have successfully connected and logged on to the remote host.
88- You can get more information by typing ` help `.
89- The most often used (simplified) sftp commands are ` ls `, ` cd `, ` put [filename] `, ` get [filename] `, and ` quit `. I said simplified since the actual commands have many more options.
90- Be aware that there will be a time you would think that nothing is happening since the cursor just stares back at you. It is always waiting for your next instruction. Typing ` quit ` or ` bye ` will close the program.
91- Congratulations. Pat yourself at the back.