FreeBSD14 ; Initial setup (Vim , SSH , firewall, NTP server)

1. Vim Install

Install Vim, which you are familiar with as an editor, as follows

Edit the ".shrc" to make Vim available as the standard editor, and log in again to reflect the change.
FreeBSD14 has sh as default shell.

You can check the current SHELL with the following command

Create a new ".vimrc" to set up the environment for using Vim, and fill in the following information

Rebooting will reflect this.

2.Use of locate database

On FreeBSD, I get the following error when using updatedb

The error message is
I am running updatedb as root user.
This would allow all logged in users to see all file names. This is a security risk.

On FreeBSD, scripts under PERIODIC are run by cron, so use the update script for the locate database that cron will run

3. SSH Connection Security Measures

3.1 SSH port changed, root user login disabled

Reflection of settings

3.2 Use public key authentication method
① Creating public and private key pairs --- logging in as a general user to create them
If you do not specify the destination and file name, id_ed25519 and id_eed25519.pub will be created in /home/(user name)/.ssh/.
On the way, enter the password for the key.

➁Save the created private key id_ed25519 to an appropriate location on windows using winSCP.

➂Edit SSH configuration file

④Connecting with TeraTerm

User name : Login User Name
Password :Password specified in the creation of a public/private key pair
Check the "Use RSA/DSA…." checkbox. and in the "Private key file" field, specify the "id_ed25519" that you just saved in windows.

SSH connection by authentication using public key cryptography can be done in the same way as other Linux, please refer to the following

4. Firewall Settings

FreeBSD has the following firewalls
・pf
・ipfw
・ipf
In this case, we will use ipfw to configure the firewall。

4.1 Check if ipfw works

4.2 Add configuration to /etc/rc.conf to use ipfw
Better to use the sysrc command than to edit the /etc/rc.conf file with a vim editor

4.3 Create additional configuration script (/usr/local/etc/ipfw.rules)

Additional configuration script content ----- for now open the following service ports
ftp (20,21), ssh (22), smtp (25), dns (53) , http (80), ntp(123) , https(443) pop3(110), imap(143), mail-over(587) , Modified SSH(2244)

System Reboot

Show ipfw list

5. NTP Server Settings

5.1 Rewrite the referenced NTP server in /etc/ntp.conf. Add an appropriate server in Japan.

5.2 Added to /etc/rc.conf to automatically start ntp at startup

5.3 Correct time
If the time is too far off, the NTP daemon will stop working, so use the ntpdate command to correct the time before starting the NTP daemon.

5.4 Time synchronization confirmation

+Servers that pass the connection test and can be referenced at any time
– Servers off the reference list in clustering checks
* Servers declared to be in reference synchronization

Copied title and URL