Linux Debian Configuration
Contents
Computer Name
nano /etc/hosts 127.0.0.1 localhost 127.0.0.1 home.frogg.fr home
hostname home.frogg.fr
.profile & /etc/profile
Each user has a file .profile in their home the scripts in this file will be esxecuted at each connexion
the /etc/profile file will be common to all users
for example:
#Time TM=`date '+%Y/%m/%d %H:%M:%S'` echo "[${TM}] ${USER} - ${SSH_CLIENT} " >> /var/log/ssh/login
Will create a login file with user information
CronTab
- doc
https://en.wikipedia.org/wiki/Cron#GNU_mcron
- crontab is a task manager
nano /etc/crontab
- syntax
Minutes Hours DayOfMonth Month DayOfWeek user command
- special commands
*/2 #half timer @reboot root {command} #each reboot
- other shortcut
@reboot @yearly @annually @monthly @weekly @daily @midnight @hourly
Script as service
- script structure (even for the comments)
#! /bin/sh
### BEGIN INIT INFO
# Provides: foobar
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: foobar
# Description: more foo for your bars
### END INIT INFO
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting foobar "
# example 1 - system service
# /usr/bin/foobar --config /etc/foo.conf start
# example 2 - run script as user
# su --login mkaz --command "/home/mkaz/bin/my-script --cmd-args"
;;
stop)
echo "Stopping foobar"
# example 1
# /usr/bin/foobar --config /etc/foo.conf stop
;;
*)
echo "Usage: /etc/init.d/foobar {start|stop}"
exit 1
;;
esac
exit 0
- copy script
sudo mv foobar /etc/init.d/ # move to init.d
sudo chmod 755 /etc/init.d/foobar # make executable
- set as stratup script
update-rc.d foobar defaults
- unset stratup script
update-rc.d -f foobar remove
- way to manually start the script as service
service foobar start
IPTables
- display content
iptables -vL -t filter
iptables -vL -t nat
iptables -vL -t mangle
iptables -vL -t raw
iptables -vL -t security
- ban an IP
#to ban an adress xxx.xxx.xxx.*
iptables -A INPUT -s xxx.xxx.xxx.0/24 -j DROP
#to ban an adress xxx.xxx.*
iptables -A INPUT -s xxx.xxx.0.0/16 -j DROP
#to ban an adress xxx.*
iptables -A INPUT -s xxx.0.0.0/8 -j DROP
#with a comment
iptables -A INPUT -s xxx.0.0.0/8 -j DROP -m comment --comment "your comment here"
- unban an IP
iptables -D INPUT -s xxx.xxx.xxx.0/24 -j DROP
Samba
service installation
apt-get install samba
edit configuration
nano /etc/samba/smb.conf
#network conf workgroup = FROGGGROUP server string = %h server dns proxy = no #log files log file = /var/log/samba/log.%m max log size = 1000 syslog = 0 panic action = /usr/share/samba/panic-action %d #Authentication [Anonymous] # <== share name path = /opt/folder browsable =yes writable = yes guest ok = yes read only = no
restart service
service samba restart
or
/etc/init.d/samba restart
set rights
chmod -R 777 /opt/folder
SFTP Chroot
- /etc/ssh/sshd_config
PasswordAuthentication yes Subsystem sftp internal-sftp -u 0007 -f AUTH -l VERBOSE Match Group {USER} ChrootDirectory {FOLDER} ForceCommand internal-sftp -u 0007 AllowTcpForwarding no GatewayPorts no X11Forwarding no
RSA Key
- /etc/ssh/sshd_config
PasswordAuthentication yes PubkeyAuthentication yes RSAAuthentication yes
Custom SSH
- login screen
nano /etc/motd
color can be added click here for the color list
- example:
echo -en "\033[1;32m" > /etc/motd
echo " _ __ _" >> /etc/motd
echo " ((-)).--.((-))" >> /etc/motd
echo " / '' \\" >> /etc/motd
echo " ( \______/ )" >> /etc/motd
echo " \ ( ) /" >> /etc/motd
echo " / /~~~~~~~~\ \\" >> /etc/motd
echo " /~~\/ / \ \/~~\\" >> /etc/motd
echo " ( ( ( ) ) )" >> /etc/motd
echo " \ \ \ \ / / / /" >> /etc/motd
echo " _\ \/ \.______./ \/ /_" >> /etc/motd
echo " ___/ /\__________/\ \___" >> /etc/motd
echo " ###############################" >> /etc/motd
echo -en "\033[1;42;97m" >> /etc/motd
echo -en "\e[1;42m" >> /etc/motd
echo " Welcome to Froggies' world ^_^ ! " >> /etc/motd
echo -en "\033[0m" >> /etc/motd
- modify user text
nano /root/.bashrc (or /home/{user}/.bashrc)
edit or modify the PS1 line
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;34m\][\[\033[01;91m\]\u\[\033[01;34m\]@\[\033[01;91m\]\h\[\033[01;34m\]]\[\033[01;34m\] \w\[\033[01;37m\] >'
SMTP Server
- install sendmail
apt-get install sendmail
OR
- install exim
apt-get install exim4
Test mail
telnet 127.0.0.1 25
And copy and paste the below
hello frogg.fr mail from:<admin@frogg.fr> rcpt to:<to_email@frogg.fr> data From: admin@frogg.fr Subject: this is a test this is test number 1 sent from linux box .
the point terminate the mail, so it is important
PHP
default mail
; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = '/usr/sbin/sendmail -t -i -f admin@frogg.fr'