# vsftpd

import { Tabs, TabsContent, TabsList, TabsTrigger } from "zudoku/ui/Tabs"

{/* vale off */}
{/* THIS FILE WAS AUTOGENERATED FROM THE PUBLIC EXAMPLE REPOSITORY. DO NOT EDIT THIS FILE DIRECTLY. */}


This guide explains how to create and deploy a [vsftpd](https://security.appspot.com/vsftpd.html) app, to secure access to the files of your VM.
To run this example, follow these steps:

1. Install the CLI.
   Use the [unikraft CLI](/cli/unikraft) or the legacy [kraft CLI](https://unikraft.org/docs/cli/install).
   You need a [BuildKit](https://github.com/moby/buildkit) builder. The easiest way to get one is via [Docker](https://docs.docker.com/engine/install/).
   Alternatively, you can also directly set up and use BuildKit, see the [quick start](https://github.com/moby/buildkit#quick-start).

:::note
The unikraft CLI is the current standard, while kraft is the legacy version.
Choose one of the CLIs below and only run the commands associated with it for the rest of this guide.
:::

2. Clone the [`examples` repository](https://github.com/unikraft-cloud/examples) and `cd` into the `examples/vsftpd` directory:

```bash
git clone https://github.com/unikraft-cloud/examples
cd examples/vsftpd/
```

Make sure to log into Unikraft Cloud and pick a [metro](/platform/metros) close to you.
This guide uses `fra` (Frankfurt, 🇩🇪):

<CodeTabs syncKey="cli">

```bash title="unikraft"
unikraft login
```

```bash title="kraft"
# Set Unikraft Cloud access token
export UKC_TOKEN=token
# Set metro to Frankfurt, DE
export UKC_METRO=fra
```

</CodeTabs>

When done, invoke the following command to deploy this app on Unikraft Cloud:

<CodeTabs syncKey="cli">

```bash title="unikraft"
unikraft volume create --set metro=fra --set name=vsftpd-workspace --set size=1G

unikraft build . --output <my-org>/vsftpd:latest
unikraft run --metro fra --scale-to-zero policy=on,cooldown-time=40000,stateful=true -p 20:20/tls -p 21:21/tls -p 222:22/tls -p 990:990/tls -p 10100:10100/tls -m 1G --volume vsftpd-workspace:/root --image <my-org>/vsftpd:latest
```

```bash title="kraft"
kraft cloud volume create --name vsftpd-workspace --size 1Gi

kraft cloud deploy --scale-to-zero on --scale-to-zero-stateful --scale-to-zero-cooldown 3s --name vsftpd -p 20:20/tls -p 21:21/tls -p 222:22/tls -p 990:990/tls -p 10100:10100/tls -M 1Gi -v vsftpd-workspace:/root .
```

</CodeTabs>

The output shows the instance address and other details:

<CodeTabs syncKey="cli">

```ansi title="unikraft"
metro:        fra
name:         vsftpd
uuid:         186a46a0-7c89-4bfd-83a8-649bcc60a96e
state:        [92mstarting[0m
image:        <my-org>/vsftpd
resources:
  memory:     1024MiB
  vcpus:      1
service:
  uuid:       4814b43a-c1d3-48f0-ef3e-9dba8bcaba25
  name:       broken-orangutan-jypu2z53
  domains:
  - fqdn:     broken-orangutan-jypu2z53.fra.unikraft.app
networks:
- uuid:       6adc6c29-5c9b-e472-70ff-fc3f3816d5a2
  private-ip: 10.0.0.109
  mac:        12:b0:17:ff:e4:c7
timestamps:
  created:    just now
```

```ansi title="kraft"
[90m[[0m[92m●[0m[90m][0m Deployed successfully!
 [90m│[0m
 [90m├[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m [90mname[0m: vsftpd
 [90m├[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m [90muuid[0m: 186a46a0-7c89-4bfd-83a8-649bcc60a96e
 [90m├[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m [90mmetro[0m: https://api.fra.unikraft.cloud/v1
 [90m├[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m [90mstate[0m: [92mstarting[0m
 [90m├[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m [90mdomain[0m: https://broken-orangutan-jypu2z53.fra.unikraft.app
 [90m├[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m [90mimage[0m: oci://unikraft.io/<my-org>/vsftpd@sha256:31aad1619c31f499b11f1bef8fead6e6df76f235a57add011e5e414a3f51ee64
 [90m├[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m [90mmemory[0m: 1024 MiB
 [90m├[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m[90m─[0m [90mservice[0m: broken-orangutan-jypu2z53
 [90m├[0m[90m─[0m [90mprivate fqdn[0m: vsftpd.internal
 [90m└[0m[90m─[0m[90m─[0m[90m─[0m [90mprivate ip[0m: 10.0.0.109
```

</CodeTabs>

This will create a volume for data persistence, and mount it at `/root` inside the VM.

In this case, the instance name is `vsftpd` and the address is `https://broken-orangutan-jypu2z53.fra.unikraft.app`.
The name was preset, but the address is different for each run.

**Note**: The `root` password defaults to `rootpass`.
Don't forget to change it inside the `Dockerfile` and update the commands below.

You can access the FTP server using a client like `lftp`:

```bash
lftp -u root,rootpass ftps://broken-orangutan-jypu2z53.fra.unikraft.app:21
lftp root@broken-orangutan-jypu2z53.fra.unikraft.app:~> ls
```

You can list information about the volume by running:

<CodeTabs syncKey="cli">

```bash title="unikraft"
unikraft volumes list
```

```bash title="kraft"
kraft cloud volume list
```

</CodeTabs>

<CodeTabs syncKey="cli">

```ansi title="unikraft"
[1mMETRO[0m  [1mNAME[0m              [1mSTATE[0m    [1mSIZE[0m    [1mCREATED[0m
fra    vsftpd-workspace  [92mmounted[0m  1.0GiB  9 minutes ago
```

```ansi title="kraft"
[1mNAME[0m              [1mCREATED AT[0m     [1mSIZE[0m     [1mATTACHED TO[0m  [1mMOUNTED BY[0m  [1mSTATE[0m    [1mPERSISTENT[0m
vsftpd-workspace  9 minutes ago  1.0 GiB  vsftpd       vsftpd      [92mmounted[0m  true
```

</CodeTabs>

You can list information about the instance by running:

<CodeTabs syncKey="cli">

```bash title="unikraft"
unikraft instances list
```

```bash title="kraft"
kraft cloud instance list
```

</CodeTabs>

<CodeTabs syncKey="cli">

```ansi title="unikraft"
[1mMETRO[0m  [1mNAME[0m    [1mSTATE[0m    [1mIMAGE[0m            [1mARGS[0m  [1mMEMORY[0m  [1mVCPUS[0m  [1mFQDN[0m                                    [1mCREATED[0m
fra    vsftpd  [94mstandby[0m  <my-org>/vsftpd        1.0GiB  1      broken-orangutan-jypu2z53.fra.unikraf…  2 minutes ago
```

```ansi title="kraft"
[1mNAME[0m    [1mFQDN[0m                                        [1mSTATE[0m    [1mSTATUS[0m   [1mIMAGE[0m                                         [1mMEMORY[0m   [1mVCPUS[0m  [1mARGS[0m  [1mBOOT TIME[0m
vsftpd  broken-orangutan-jypu2z53.fra.unikraft.app  [94mstandby[0m  standby  oci://unikraft.io/<my-org>/vsftpd@sha256:...  1.0 GiB  1            7.19 ms
```

</CodeTabs>

When done, you can remove the instance:

<CodeTabs syncKey="cli">

```bash title="unikraft"
unikraft instances delete vsftpd
```

```bash title="kraft"
kraft cloud instance remove vsftpd
```

</CodeTabs>

The volume isn't removed by default, so you can recreate the instance and still have access to your old data.
Remove it using:

<CodeTabs syncKey="cli">

```bash title="unikraft"
unikraft volume delete vsftpd-workspace
```

```bash title="kraft"
kraft cloud volume remove vsftpd-workspace
```

</CodeTabs>

## Learn more

Use the `--help` option for detailed information on using Unikraft Cloud:

<CodeTabs syncKey="cli">

```bash title="unikraft"
unikraft --help
```

```bash title="kraft"
kraft cloud --help
```

</CodeTabs>

Or visit the [CLI Reference](/cli/unikraft) or the [legacy CLI Reference](/cli/kraft/overview).
{/* vale on */}
