Skip to content

Instantly share code, notes, and snippets.

@junetech
Last active March 4, 2021 02:04
Show Gist options
  • Save junetech/46c784d7c35c040657af767151b85349 to your computer and use it in GitHub Desktop.
Save junetech/46c784d7c35c040657af767151b85349 to your computer and use it in GitHub Desktop.
Fedora Server initial settings

Initial settings for Fedora Server

based on version 33

Static IP address using CLI

  • Find interface name(e.g. enp42s0) by $ ifconfig -a
  • Make & edit the interface's config file by $ sudo nano /etc/sysconfig/network-scripts/ifcfg-enp42s0
    • put the informations by the following format:
    DEVICE=enp42s0
    BOOTPROTO=static
    ONBOOT=yes
    IPADDR=112.112.112.112
    NETMASK=255.255.0.0
    GATEWAY=119.119.119.119
    DNS1=1.1.1.1
    DNS2=8.8.8.8
    
  • Restart network/NetworkManager services by:
    $ su
    # systemctl restart network.service
    # systemctl restart NeworkManager.service
    # exit

Change SSH port

  • Open OpenSSH config by $ sudo nano /etc/ssh/sshd_config
    • Find #Port 22 and change to desired port(e.g. 33000) by putting Port 33000
  • Allow new SSH port on SELinux
    $ su
    # semanage port -l | grep ssh
    # semanage port -a -t ssh_port_t -p tcp 33000
    # semanage port -l | grep ssh
    # systemctl restart sshd
    # exit
    $ netstat -tunl | grep 33000
  • FirewallD: Open the port for your zone
    • Check the active zone by ``
    • Open the port in the zone by ``
    • Reload
    $ firewall-cmd --get-active-zones
    $ su
    # firewall-cmd --zone=FedoraServer --add-port=5000/tcp --permanent
    # firewall-cmd --reload
    # firewall-cmd --list-ports
    # exit

Enable SSH key-based authentication

  • If key exists:
    • Change file/folder permissions by $ chmod 700 ~/.ssh; chmod 600 ~/.ssh/id_ed25519; chmod 644 ~/.ssh/id_ed25519.pub
  • Else:
    • Create new key pair by $ ssh-keygen -t ed25519
  • Add to authorized_keys by $ cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys
  • Optional: disable password authentication
    • Open OpenSSH config by $ sudo nano /etc/ssh/sshd_config
    • Find #PasswordAuthentication yes and change to PasswordAuthentication no

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment