# FreeBSD vm Quick Startup



## aa (Mar 12, 2017)

Hello, with freebsd vm images now also deployed as official distribution,
I'd like to share some first-run VMWare tips for beginner to start up quickly.

Preparation:

Extract freebsd-xxx.vmdk.xz VMWare image: 7z x freebsd-xxx.vmdk.xz.
Create a new virtual machine with extracted image as disk.

Steps:

Copy the script block below.
Run the virtual machine (obviously).
Click inside the virtual machine's window.
Press 2 to boot to single-user mode, then just press [ENTER] to login,
or if you missed it, at the initial login prompt, type: *root* then [ENTER].
press [CTRL-ALT] to escape focus.
Paste the script, Press [CTRL-V] or Click Edit->Paste.
*Done*. You can now connect to the new vm with *ssh *and *ftp *as *root*/admin or *user*/user

What does the script do?

Create *root* password: *admin *and change its shell to sh.
Create a user which may su, login: *user*, password: *user*.
Setup host for dhcp client, disable some extras (mail,motd,vi/tmp cleanup).
Setup ftp and ssh services that permit root access.
Replace *more* with *less* as PAGER.
Some sample profile.
======== START TO BE COPIED BELOW ========
	
	



```
exec sh
mount -uw /
cd /etc

sed -i "" '/^.ftp/s/^.//' inetd.conf
sed -i "" '/^root/s//#&/' ftpusers
sed -i "" 's/^. *\(PermitRoo.* \).*$/\1yes/' ssh/sshd_config
sed -i "" 's/=more/=less/' ~/.profile

echo admin | pw mod user root -ssh -h0
pw add user ftp -h- -u14 -d/ -s/usr/sbin/nologin

u=user
echo user | pw adduser $u -h0 -G0 -d /home/$u
mkdir -p /usr/home/$u
ln -s usr/home /
chown $u:$u /home/$u

mv motd m
FILTER='sed -n /[[:print:]]/p'

cat << EOF | $FILTER > /boot/loader.conf
autoboot_delay=1
#vesa_load=yes
EOF

cat << EOF | $FILTER > rc.conf
ifconfig_em0=dhcp
inetd_enable=yes
sshd_enable=yes
hostname=aa.freebsd.box
allscreens_kbdflags="-b10.50"
sendmail_enable=NONE
clear_tmp_X=no
cleanvar_enable=no
virecover_enable=no
update_motd=no
EOF

cat << EOF | $FILTER > profile
set -o emacs
alias x=exit
alias vip='${EDITOR:-vi} /etc/profile'
alias soup='. /etc/profile'
alias md=mkdir
alias cls='tput -T $TERM clear'
EOF

reboot
```
======== END TO BE COPIED ABOVE ========
Notes:

CR/LF pair will ruins HERE<<DOCS on pasted text, hence the FILTER.
You may freely modify the script (minimize, change user/password etc.)
but remember that upto v10 it can not exceed MAX_INPUT 1024 bytes in size.
You might wanted to install bash later *for user*, FreeBSD's sh doesn't
have a tab completion, it's not intended for interactive user
(but please don't change the *root* shell with bash)
Caveat:

Copy/Paste between Host and FreeBSD Guest only works on VMWare v10+
If you are using Oracle's VirtualBox make sure Shared Clipboard is on
(Settings -> General -> Advanced: Shared Clipboard = Bidirectional),
I mean, you can try, I never get copy/paste to work on VirtualBox .


----------

