Edit System Hostname
This is to manually change the system so it understands the hosts name and fqdn or the host.
1- Edit the hosts file
- sudo nano /etc/hosts
- change the second 127.0.0.1 hostname to 127.0.0.1 name.domain.com name
- close and save the file
2- Edit the hostname file
- sudo nano /etc/hostname
- remove the single line of text and replace it with just the host name (without the domain.com)
3- Reboot your system
UFW For Ubuntu
Please use the following web page for full information on the commands I reference below. UFW Essentials
1- sudo ufw enable
2- sudo ufw default deny incoming
3- sudo ufw default allow outgoing
4- sudo ufw default deny routed
Is SSH Running on Port 22 (5a) or a Custom Port(5b)?
5a- ufw allow ssh or ufw allow openssh (depending on application reference each allow TCP port 22)
5b- sudo cp /etc/ufw/applications.d/openssh-server /etc/ufw/applications.d/customssh
6- sudo nano /etc/ufw/applications.d/customssh
change the [OpenSSH] to [customssh]
change the application name to custom ssh server
leave description alone so you know it later references openssh services
change the port number to the port your ssh server uses ex: 1022/tcp
press ctrl + x to exit editing and press y and hit enter to save the file
7- sudo ufw allow customssh
8- sudo ufw reload
for more advanced setting please use the reference at the top of the article
SSH Keys for Users via PuttyGen
- Launch the PuTTYgen application on your local computer.
- Locate the Parameters section at the bottom of the window.
- Choose your key type; Ed25519 or RSA (minimum 2048 bits) are highly recommended.
- Click the Generate button.
- Move your mouse cursor randomly over the blank space to generate entropy until the progress bar fills.
- Locate the Key passphrase and Confirm passphrase fields.
- Type a secure password to protect your private key file.
- Click Save private key.
- Save the file with a
.ppkextension in a secure location on your local machine. - Do not close the PuTTYgen window yet.
- Go to the text box at the top labeled “Public key for pasting into OpenSSH authorized_keys file”.
- Right-click inside that box and select Select All.
- Press
Ctrl + Cto copy the entire public key string.
- Create the SSH directory for your user if it does not exist:
mkdir -p ~/.ssh - Open or create the
authorized_keysfile using a text editor like Nano:nano ~/.ssh/authorized_keys - Paste the copied public key string into the file (Ensure it stays on a single line).
- Save and exit the editor (Press
Ctrl + O,Enter, thenCtrl + X). - Restrict permissions on the directory and file to secure them (you must set to this any lax permissions and it wont load the key):
chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys
- Open the main PuTTY application.
- Enter your Ubuntu server's IP address or hostname under Session.
- Navigate to Connection > SSH > Auth > Credentials in the left sidebar sidebar.
- Click Browse next to “Private key file for authentication”.
- Select the
.ppkfile you saved in Step 2. - Return to Session, give it a name under Saved Sessions, and click Save.
- Click Open and enter your Ubuntu username and key passphrase to connect.
Reference : Google Search