Puffy Spezial

Page content

Some OpenBSD Tipps and Trick. You may also check the Blogs directly …

PF Rule Expander

# ipv4
echo "pass log inet proto tcp from any to self port 22" |pfctl -nvf - |sort

# ipv6
echo "pass log inet proto tcp from any to self port 22" |pfctl -nvf - |sort

# dualstack
echo "pass log proto tcp from any to self port 22" |pfctl -nvf - |sort

remove File based on Inode

you have files with strange name which you can’t delete. try this.

ls -il -> grab nr
find . -inum $mynr -exec ls -i {} \;
find . -inum $mynr -exec rm -i {} \;

boot from usb stick

if you attach your usb stick, you will get an additional drive, here hd1+. you can boot from this stick and do a fresh install, upgrade, autoinstall as you want :)

Using drive 0, partition 3.
probing: pc0 com0 com1 mem[638K 1918M a20=on]
disk: hd0+ hd1+
>> OpenBSD/amd64 BOOT 3.33
boot> boot hd1d:/bsd.rd

Backup File

simple backup a file with shell expanding

doas cp /etc/hosts{,.bak}

Test SSH Config and Failback

need to test a config and failback if you locked out yourself ? -> you’ve got two minutes to reattach tmux and stop the command or your sshd_config will fail back :)

cd /etc/ssh
cp sshd_config{,.bak}
update your sshd_config with your dirty hack
rcctl restart sshd && sleep 120 && mv sshd_config{.bak,} && rcctl restart sshd

Count Open File Descriptors for Process ID

# fstat -np 43704 |echo $(($(wc -l)-1))

8 Port USB/Serial Box, how to activate Port 5-8

cd /dev; ./MAKEDEV ttyU4 ttyU5 ttyU6 ttyU7

OpenBSD Crontab

Run once, at startup
@yearly   Every January 1 (0 0 1 1 *)
@monthly  Run the first day of every month (0 0 1 * *)
@weekly   Run every Sunday (0 0 * * 0)
@daily    Run every (0 0 * * *)
@hourly   Every hour (0 * * * *)

ASCII to binary

$ echo ASCII to binary | xxd -b -c1 | cut -d\  -f2

OpenBSD hier — layout of filesystems

hier manpage

Default Mail Forwarder

echo gott@world.net > $HOME/.forward

is your host ready for virtualization ?

dmesg |egrep '(VMX/EPT|SVM/RVI)' || echo "NOT READY for virtualization"

README from the OpenBSD packages


combine cat & echo

$ echo "hallo hosts" | { cat; head -1 /etc/hosts; echo "bye hosts"; } 
hallo hosts	localhost
bye hosts

Multiline Regex

find # MyStuff

$ pcregrep -M '#\n# My.*\n#' /etc/acme-client.conf 
# My Stuff

Multiline Regex2



# bla bla bla


in /etc/*

pcregrep -M '^$\n#.*\n#.*\n#.*\n^$\n' /etc/*

Sort File

hint: “cat somefile |sort > somefile” will not work as the file “somefile” will be erased before sending it’s content to the sort programm

sort -o file file

or (shorter)

sort -o file{,}

Firmware for APU


or local mirror (v4.13.0.6)

Firmware for APU2, APU3, APU4

sha256: 53b906dbf9f592d6c9af204636061b54e148816d70ae512da1a507096b90594c