Setting up a new Linux server

More lessons from the trenches while dabbling with Linux. I love the way Linux is so easy to re-install from scratch. These are the steps I used when I was managing my own server on Linode. They have some great documentation which helped a lot.

While logged in as root run the following commands to setup a new user

adduser yourusername
usermod -a -G sudo yourusername
logout

(On Linux use `scp /path/to/file user@host:/path/to/destination`) to copy files to and from a server.

To setup ssh authentication using Winscp and the the new user login copy ida_rsa.pub to the server. Then run the following commands

mkdir .ssh
mv ida_rsa.pub .ssh/authorized_keys
chown -R yourusername:yourusername .ssh
chmod 700 .ssh
chmod 600 .ssh/authorized_keys

To disable root login form ssh do (but make sure you can login as another user first don’t lock yourself out!)

sudo apt-get install vim
sudo vim /etc/ssh/sshd_config
PasswordAuthentication no
PermitRootLogin no
sudo service ssh restart

To install a firewall run

sudo apt-get install ufw
sudo ufw allow 80
sudo ufw allow 22
sudo ufw allow 1022
sudo ufw allow 443
sudo ufw enable

To get the latest version of your Linux distro/operating system

upgrade distro
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s