Skip to content

Instantly share code, notes, and snippets.

@bborysenko
Forked from blakerohde/CENTOS-SETUP-GUIDE.rst
Created December 6, 2013 10:57
Show Gist options
  • Save bborysenko/7821963 to your computer and use it in GitHub Desktop.
Save bborysenko/7821963 to your computer and use it in GitHub Desktop.

CentOS Server Setup

Initial Setup

  1. Copy firewall shell script and modify it accordingly. Run it.

  2. Run $ su -c 'visudo' and add USERNAME ALL=(ALL) ALL for each allowed USERNAME.

  3. Update the system: $ sudo yum upgrade.

  4. Add the RHEL EPEL Repo:

    $ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    $ sudo rpm -Uvh epel-release-6*.rpm
    
  5. Setup SSH by editing /etc/ssh/sshd_config and adding/editing the following lines. Note each allowed SSH user must replace USERNAME1, USERNAME2, etc. below.

    Port 7331
    PermitRootLogin no
    UseDNS no
    AllowUsers USERNAME1 USERNAME2
    
  6. Now restart the SSH service: $ sudo service sshd restart.

  7. Enable the SSH service: $ sudo chkconfig sshd on.

SSH Key Setup

On your local PC:

  1. Create a key:

    $ cd ~/.ssh
    $ ssh-keygen -t rsa -f USERNAME_rsa
    $ chmod 700 ~/.ssh
    $ chmod 600 ~/.ssh/USERNAME_rsa
    
  2. Copy the public key to the server, eg. $ scp -P 7331 ~/.ssh/USERNAME_rsa.pub USERNAME@SERVER_ADDRESS:/home/USERNAME/.

  3. Ensure the correct SELinux contexts are set: $ restorecon -Rv ~/.ssh.

On the CentOS server:

  1. Append the public key to the profile's authorized_keys SSH file and set file permissions:

    $ cat USERNAME_rsa.pub >> ~/.ssh/authorized_keys
    $ chmod 700 ~/.ssh
    $ chmod 600 ~/.ssh/authorized_keys
    
  2. Ensure the correct SELinux contexts are set: $ restorecon -Rv ~/.ssh.

Rename Server Host

  1. Open /etc/sysconfig/network file and modify the HOSTNAME= value to match your FQDN host name: $ sudo vi /etc/sysconfig/network.
  2. Open /etc/hosts file and modify any line referencing the old HOSTNAME to point to the new HOSTNAME.
  3. Run the hostname command to see the current/old HOSTNAME and then run again with the first argument to set the new HOSTNAME: $ sudo hostname and $ sudo hostname NEW_HOSTNAME.
  4. Restart the networking service: $ sudo /etc/init.d/network restart.

Auto-mounting External Drive

  1. Find the device by its mount point: $ sudo fstab -l.
  2. Get the devices associated UUID: $ ls -l /dev/disk/by-uuid (this will allow you to plugin the device into any other port on the computer).
  3. Create the mount directory: $ sudo mkdir /mnt/rb1tb.
  4. Edit the fstab file: $ sudo vi /etc/fstab.
  5. Add the following line to the file: UUID=43d65df3-ad4e-447e-ac97-a992c1dbe427 /mnt/rb1tb ext4 defaults 1 1.

Configuration of Python

  1. Install easy_install: $ sudo yum install python-setuptools.
  2. Install pip: $ sudo easy_install pip.

Adding a Script to Cron

  1. Set your script to be executable: $ chmod 755 script.py.
  2. Create a symbolic link to the file in cron: $ ln -s /PATH/TO/script.py /etc/cron.hourly/.

Installing Git-Annex

NOTE 1: If you are using the steps below for your client computer with Fedora/CentOS/RHEL, it is recommended to replace the references to /usr/local/bin with $HOME/bin. Note also that if you do this, you do not need to run the associated command with sudo.

NOTE 2: If installing on a client computer with Fedora/CentOS/RHEL: skip step 5 and make sure $HOME/bin is in your PATH environment variable. If it isn't add export PATH=$PATH:$HOME/bin to ~/.bashrc and run $ source ~/.bashrc.

  1. Install dependencies via YUM: $ sudo yum install haskell-platform gnutls-devel libgsasl-devel libxml2-devel zlib-devel ghc-zlib-devel libidn-devel.
  2. Update cabal: $ cabal update.
  3. If needed, upgrade cabal: $ cabal install cabal-install.
  4. Install c2hs: $ sudo cabal install c2hs --bindir=/usr/local/bin/.
  5. Create symbolic link for c2hs within /usr/sbin so you can run it as sudo or root: $ sudo ln -s /usr/local/bin/c2hs /usr/sbin/.
  6. Finally, install git-annex: $ sudo cabal install git-annex --bindir=/usr/local/bin/.
  7. If you encounter any errors with the installation, with regards to the Glasgow Haskell Compiler (ghc) see below.

Error with ghc While Installing Git-Annex

You will have to compile the newest version by going to the website http://justhub.org/download (as recommended on http://www.haskell.org/platform/linux.html).

  1. Download the rpm for CentOS 6: $ wget http://sherkin.justhub.org/el6/RPMS/x86_64/justhub-release-2.0-4.0.el6.x86_64.rpm.
  2. Add the rpm to Yum: $ sudo -ivh justhub-release-2.0-4.0.el6.x86_64.rpm.
  3. Now install Haskell: $ sudo yum install haskell.
  4. You might have received an error about the existing compiler, remove it using: $ sudo yum remove [package(s)].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment