業務用エアコン関連の技術情報、エラーコード、環境問題対策に関する別サイト「エアコンの安全な修理・適切なフロン回収」

FreeBSD14.4 : Initial settings (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 private key you created (id_ed25519) to a location of your choice on Windows using WinSCP.
Start Winscp
Host name  :  Server IP address
Port number : SSH Port
User name : Server login user
Password : The same user's password
「Save」

Site name : Any name
Click "OK"

After verifying the server, click "Login"

If the screen below appears, click "Update"

In the "Password" field, enter the user's password

Once connected, the left pane shows the server side, and the right pane shows the PC (Windows) side.
Save the "id_ed25519" file located in the .ssh directory to a suitable location on the Windows side (in the right pane).

➂Edit the SSH configuration file

④Connecting via TeraTerm

User name : Login username
Password :The password specified when creating the public/private key pair
Check the "Use RSA/DSA…" box, and in the "Private key file" field, specify the "id_ed25519" file you saved to Windows earlier.

SSH connections using public-key authentication can be established in the same way as on other Linux systems; please refer to the following instructions.

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