I quite often spin up virtual machines on which to test something on the Mac, and after VirtualBox finishes doing what it’s supposed to, I typically wish to access them via SSH but cannot easily, as I don’t know their dynamically assigned IP address or I’ve forgotten the address I assigned statically.


Sebastien showed us how to do it on Linux: the magic capabilities are already hidden within agetty(8), in the section on /etc/issue files.

When I modify /etc/issue to contain the IP4 line:

Kernel \r on an ]\m
IP4: \4{enp0s3} \4{enp0s8}

I’m rewarded with this:

console Linux


On FreeBSD, the situation is a bit more involved but very flexible.

The ttys(5) file defines how getty(8) is invoked on a terminal, and passes it a terminal type (e.g. Pc) which getty searches for in gettytab(5).

ttyv0   "/usr/libexec/getty Pc"         xterm   onifexists secure

The Pc entry is in the the termcap-like gettytab file:

P|Pc|Pc console:\

The first three capabilities specify the terminal has real tabs (ht), doesn’t use parity (np), has a line speed (sp) of 9600, and I add the if and iM strings to it:

  • if means getty should display the named file before the prompt (/etc/issue type)
  • iM points to a program which can generate an initial banner message (normally from im but I use if)

So, with a very crude /etc/jp.sh consisting of:



echo "********* $(date) ******* BLA" > /etc/jp.banner

/sbin/ifconfig $iface |
    awk 'BEGIN { getline ; IFACE = $1; }
        /inet / { print "IP4: " IFACE " " $2;}
        /inet6/ {  if ( $2 !~ /^fe80/ ) { print "IP6: " IFACE " " $2; } }'

we end up with a FreeBSD console showing this:

console FreeBSD

Thanks to Trix for the awk mess ;-)


On OpenBSD, the configuration is similar to that on FreeBSD, but the capabilities in OpenBSD’s gettytab(5) are reduced to a minimum with simply the im capability (initial banner message). There are a few character sequences which can be included in that (e.g. %d for the date or %h for the hostname), but I don’t see how to add interface data to the banner other than actually in-place editing /etc/gettytab on boot.

Philipp suggests I do this in /etc/rc.local:


for iface in em0 em1; do
	ip="$(ifconfig $iface | awk '/inet / { print $2 }') "
	data="$data $ip"

sed -i.bak "/:im=/s|(%h.*(|(%h $data) (|"  /etc/gettytab

openbsd console

Enough for now. :)

linux and unix :: 18 Dec 2019 :: e-mail