# Proxmox | Cloud-Init initialization using FreeBSD VM QCOW2 image



## FlorinMarian (May 3, 2022)

Hello!
I managed to successfully clone the FreeBSD images for versions 12.3 and 13.0 but I have two small issues with the "FreeBSD - cloudinit" combination.
Specifically, I intend to activate the `sshd` service from the first boot and set the root user password.
The lines below do exactly the right thing in Linux but not in FreeBSD.


```
chpasswd:
  list: |
     root:RANDOM-PASSWORD
  expire: True
```



```
runcmd:
  - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
  - sed -i -e ' root' /etc/ssh/sshd_config
  - systemctl restart sshd
```

Any tip is welcome.

EDIT: I realised that default images don't have cloud-init installed.


----------



## BjarneB (May 3, 2022)

sed -i on linux means inline editing, on FreeBSD it means extension.
There is no equivalent to linux sed -i.   On FreeBSD you will need to use intermediate files.


----------



## SirDice (May 3, 2022)

BjarneB said:


> sed -i on linux means inline editing, on FreeBSD it means extension.
> There is no equivalent to linux sed -i. On FreeBSD you will need to use intermediate files.


No. On FreeBSD `-i` _requires_ an argument, on Linux that argument is _optional_. `sed -i "" ...` will work the same on Linux and FreeBSD.


```
-i extension
             Edit files in-place similarly to -I, but treat each file
             independently from other files.  In particular, line numbers in
             each file start at 1, the “$” address matches the last line of
             the current file, and address ranges are limited to the current
             file.  (See Sed Addresses.) The net result is as though each file
             were edited by a separate sed instance.
```



FlorinMarian said:


> The lines below do exactly the right thing in Linux but not in FreeBSD.


Note that `systemctl restart sshd` obviously won't work on FreeBSD. If you use `service sshd restart` then it'll work on both Linux and FreeBSD.


----------



## FlorinMarian (May 3, 2022)

SirDice said:


> No. On FreeBSD `-i` _requires_ an argument, on Linux that argument is _optional_. `sed -i "" ...` will work the same on Linux and FreeBSD.
> 
> 
> ```
> ...


Thank you for feedback!
Is there any way to include cloud-init into default VM template without rebuilding it?


----------

