• Update to latest patches
○ Ubuntu
§ sudo apt update
§ sudo apt dist-upgrade
○ Fedora
§ dnf update
• Ubuntu
○ login with root or sudo user
§ adduser NAME
§ if needed change user to sudo group
§ usermod -aG sudo NAME
• Fedora
○ Log in with root or sudo user
§ adduser -m -g users -G wheel NAME
□ -m = add a home directory
□ -g assigns the group
□ -G adds to the sudo group
• Set the hostname and hosts file
○ hostnamectl set-hostname name-for-server
§ Change name-for-server to desired name
§ Use domain name here if desired
○ nano /etc/hosts
○ Leave localhost at default
§ Add a line
§ 127.0.1.1 name-for-server
□ Name-for-server is what was set in the hostname
• setup firewall if needed
○ ufw allow OpenSSH
○ ufw enable
○ ufw status to check the status of the firewall
• Create ssh key if needed on host computer
○ ssh-keygen -t ed25519 -C "Comment for ssh key"
§ "Comment for ssh key" = what you want to show at the end of your ssh key
○ ssh-keygen -t ed25519 -C "Comment for ssh key"
§ to create a ssh key to use with specific servers of programs
• Copy ssh key to the server
○ ssh-copy-id username@remote_host
○ ssh-copy-id -i ~/.ssh/<keyname>.pub
§ to copy specific public key to server
○ ssh -i .ssh/<key_name> <IP Address>
§ to use specific key to log into a server
• eval $(ssh-agent)
• ssh-add
• = caching the passphrase with ssh agent
• alias ssha='eval $(ssh-agent) && ssh-add' to create an alias to put in .bashrc
• disable root login and password log in (make sure you can connect with ssh key before doing this)
• sudo nano /etc/ssh/sshd_config
• change PasswordAuthentication yes to PasswordAuthentication no
• chage allowrootlogin yes - allowrootlogin no
• sudo systemctl restart sshd
• If you’re using the root account to set up keys for a user account
• it’s also important that the ~/.ssh directory belongs to the user and not to root: chown -R sammy:sammy ~/.ssh
Leave a Reply
You must be logged in to post a comment.