Sunday, October 23, 2011

Configuring network and SSH in NetBSD

I have set up my old workstation (AMD Duron with 1.2GHz and 512MB of Ram) with the current NetBSD release 5.1 to play a little around with it. I installed it in a VM (without any networking hardware) directly on the harddisk and after installation I placed the harddisk into the computer. When the OS is booted, I took a look at the networking hardware: 

# ifconfig -a
        address: 00:10:dc:2f:86:6c
        media: Ethernet autoselect (100baseTX full-duplex)


To set an IP permanently I have to configure /etc/ifconfig.tlp0

# vi /etc/ifconfig.tlp0
inet netmask

The default route is set in /etc/mygate:

# vi /etc/mygate

Edit /etc/resolv.conf for DNS:

# vi /etc/resolv.conf

And finally set the name of the machine in /etc/myname:

# vi /etc/myname

Reboot the machine to check if the settings will be set while booting. If everything works then configure SSH. If you want to login as root via ssh then edit the sshd_config file first:

# vi /etc/ssh/sshd_config
PermitRootLogin yes

Then add sshd to rc.conf at the end:

# vi /etc/rc.conf

Finally, first start your network:

# /etc/rc.d/network start

And then ssh:

# /etc/rc.d/sshd start

The script will first create the host keys and then start the ssh daemon. From this point you should be able to login as root over your network into your NetBSD machine.