Configuration - marco1475/linux-htpc GitHub Wiki
-
Edit
/etc/environment:# Make vim the default editor EDITOR="/usr/bin/vim" VISUAL="/usr/bin/vim" -
Use
systemd-timesyncdto synchronize your system clock using NTP:timedatectl set-ntp true
-
Create the
marco1475user:useradd -m -G users,wheel -s /bin/bash marco1475 -
Give the
marco1475user a password:passwd marco1475 -
Add the
marco1475user to thesudoersfile:Defaults requiretty marco1475 ALL=(ALL) ALL
-
Install the
mlocatepackage:pacman -S mlocate -
Run
updatedbas root to initialize the database:updatedb -
By default
updatedbinstalls a timer (/usr/lib/systemd/system/updatedb.timer) that runs it daily.
-
Install the
atpackage:pacman -S at -
Start the
atddaemon and enable it on boot:systemctl start atd.service systemctl enable atd.service -
Test that it is working:
/usr/bin/echo "/usr/bin/echo 'Test At' | /usr/bin/sendmail <e-mail address>" | /usr/bin/at now + 1 minute
-
Install the
wgetpackage:pacman -S wget
-
Install the
tmuxpackage:pacman -S tmux -
Edit the
~/.tmux.conffile:- TODO
-
Install the
irssipackage:pacman -S irssi -
Edit the
~/.irssi/configfile:- TODO
-
Install the
opensshpackage:pacman -S openssh -
Configure the SSH daemon (
sshd) by modifying/etc/ssh/sshd_config:Port 22 PermitRootLogin no ChallengeResponseAuthentication no Banner /etc/issue AllowUser marco1475 -
Start the SSH daemon as a socket (with on-demand daemon instantiation):
-
Create a drop-in configuration file for the
sshd.socketservice:systemctl edit sshd.socket -
Add the following to the configuration file and save it as as
/etc/systemd/system/sshd.socket.d/override.conf:[Socket] ListenStream= ListenStream=22- The first
ListenStream=line is needed to prevent SSH from listening on the default port 22.
- The first
-
Start and enable the service:
systemctl start sshd.socket systemctl enable sshd.socket
-
-
Copy your SSH public key to the server (if you don't have one, create either an SSH or OpenPGP keypair):
-
Copy the
id_rsa.pubpublic key to the server:scp ~/.ssh/id_rsa.pub marco1475@babylon5:
-
If the user does not have a
~/.sshdirectory, create it:mkdir ~/.ssh chmod 700 ~/.ssh -
Add the public key to the user's
authorized_keysfile on the server:cat ~/id_rsa.pub >> ~/.ssh/authorized_keys rm ~/id_rsa.pub chmod 400 ~/.ssh/authorized_keys -
Restart the SSH service:
systemctl restart sshd.socket
-
- FTP is much less secure than SFTP or SCP, so do not enable it on the server.
- If for some reason you must, here are some tips:
-
Create a custom FTP user, so you can limit which parts of the file system are exposed via FTP.
-
The user's home directory will be used as the root of a chroot jail, which means the user cannot have write access to that directory.
-
This affects only the root directory itself, the user can (and should) have write access to all sub-directories.
-
However, this makes it hard to chroot jail a normal user, because a lot of processes write to ~.
-
You can change the write access to user's home directory by executing:
chmod a-w \<path_to_home\>
-
-
Make the user's home directory
/srv/ftpand make that the only FTP writable directory. -
Use FTP to only upload data to the server; reading data should be done through other applications, i.e.
mpd,kodi, etc. -
Only the listen port is hard-coded; after the initial connection is established, the FTP daemon will randomly choose a (passive) port to transfer data over.
-
Enable the
nf_conntrack_ftpkernel module which tracks the randomly-assigned transfer port and updatesiptablesaccordingly:echo nf_conntrack_ftp > /etc/modules-load.d/nf_conntrack_ftp.conf -
Don't forget to update
iptablesaccordingly:iptables -A PREROUTING -t raw -p tcp --dport 21 -j CT --helper ftp iptables-save > /etc/iptables/iptables.rules
-
-
etckeeper is a collection of tools to let /etc be stored in a git, mercurial, bazaar or darcs repository.
-
Since
/etcis not user-writable, the following steps should be done asroot. -
Install
etckeeper:pacman -S etckeeper -
Configure git:
-
Set up the user configuration file (
~/.gitconfig):git config --global user.name "Babylon 5 Server" git config --global user.email "[email protected]" -
(Optional) Set up a remote repository:
git remote add origin https://<repository-address>.git -
(Optional) Set up
clean/smudgescripts to avoid exposing sensitive data:-
Create a
.gitattributesfile in the git directory (in this case/etc) with the following content:<pattern> filter=<filter_name>-
<pattern>is a file glob (e.g.*.conf). -
<filter_name>is a custom name for your filter that has to match a filter section in your.gitconfig.
-
-
Add a filter to your
.gitconfig:git config --global filter.<filter_name>.clean "<script> <parameters>" git config --global filter.<filter_name>.smudge "<script> <parameters>"-
<filter_name>is a custom name for your filter that has to match a filter command in the git directory's.gitattributefile. -
<script>and<parameters>are either a binary executable or a locally-executable script and the parameters it needs to process the contents of any file matched by<pattern>(from.gitattributes) piped to it usingSTDIN.
-
-
-
-
Initialize
etckeeperin the/etcdirectory (this creates a local repository):cd /etc etckeeper init -
Check which files will be added to source control:
git status -
Commit the files:
git commit -m <message>-
<message>is your custom commit message.
-
-
(Optional) Push your local repository to the remote repository:
git push -u origin master-
etckeepercan automatically push your local repository to the remote repository with thePUSH_REMOTEhook in/etc/etckeeper/etckeeper.conf:PUSH_REMOTE="origin"
-
-
Garbage-collect your
/etcrepository to save space:git gc -
Enable and start the
systemdtimer:systemd start etckeeper.timer systemd enable etckeeper.timer