Skip to content

Latest commit

 

History

History
179 lines (177 loc) · 4.86 KB

Server.md

File metadata and controls

179 lines (177 loc) · 4.86 KB

Samba Server

Add a samba user if the same unix user exists

sudo apt install samba 
sudo smbpasswd -a $USER

Config

cat << EOF > /etc/samba/smb.conf 
[global]
   workgroup = WORKGROUP
   server string = %h server (Samba, Ubuntu)
   log file = /var/log/samba/log.%m
   max log size = 1000
   logging = file
   panic action = /usr/share/samba/panic-action %d
   server role = standalone server
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
   map to guest = bad user
   bind interfaces only = yes
   interfaces = lo enp3s0
[nuc]
    comment = Samba on Ubuntu
    path = /var/www/html
    read only = no
    guest ok  = yes
    browsable = yes
    create mask = 0644
    directory mask = 0755
    public = yes
    force user = [YOUR_USERNAME]
EOF

Smbclient

sudo apt install smbclient
smbclient //ip/share_folder -U '%' -c "put somefile"
smbclient '\\192.168.1.123\someDir' -c 'prompt OFF;lcd "localDir";mput movie.mp4' -U userName passwd

FTP Client

ftp -inv ftp.ebi.ac.uk <<EOF
user anonymous {mypassword}
cd pub/databases/msd/sifts/xml
mget 5z*.xml.gz 
bye
EOF

Or

ftp -inv ftp.ebi.ac.uk <<EOF
user anonymous {mypassword}
cd pub/databases/msd/sifts/xml
get 5z8t.xml.gz
get 5z51.xml.gz
get 5zu3.xml.gz
bye
EOF

list local dir

!ls 

NFS Client

sudo apt install nfs-common
showmount -e 192.168.1.123 
# Export list for 192.168.1.123:
# /mnt/someDir 192.168.1.0/24
mount 192.168.1.123:/mnt/someDir /nfs/general

DHCP Server

  • Assume eth0 is already configured with ip 192.168.3.3/24 (Otherwise dhcpd will fail to start)
  • A dhcp server (dhcpd) can be started for 192.168.3.0/24
sudo apt install isc-dhcp-server
cat << EOF > /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;

subnet 192.168.3.0 netmask 255.255.255.0 {
 range 192.168.3.100 192.168.3.200;
 option routers 192.168.3.3;
 option domain-name-servers 8.8.8.8, 8.8.4.4; 
}
EOF
cat << EOF > /etc/default/isc-dhcp-server # specify the interfaces dhcpd should listen to.
INTERFACESv4="eth0"
EOF
sudo systemctl restart isc-dhcp-server.service
  • dhcpd’s messages are being sent to syslog.
  • List dhcpd's users

rsync Server

cat << EOF > /etc/rsyncd.conf
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsync.log
port = 8873

[my_remote_dir]
path = /tmp/rsync
comment = Rsync files
timeout = 300
read only = false
EOF
rsync --daemon
rsync -azP /local_dir/ rsync://host:port/my_remote_dir/
  • Rsync recurrently
rsync -azv --delete /mnt/e/ /mnt/h/
  • Folder exclusion (you cannot exclude '/var/www/html/software/docker' because there is no '/var/www/html/software/docker' under '/var/www')
rsync -rtP --exclude 'www/html/software/docker' /var/www /media/aaa/AutoChem_Backup/

Email Server (Not working for AWS Host. Additional configuration is needed for AWS)

  1. Add a MX record to DNS registrar
Name   Type    Data
@      MX      10 guoxiaokang.com.
  1. Install MTA (Message Transfer Agent)
apt update && apt install -y postfix
  1. Install MUA (Mail User Agent)
apt install -y mailutils
  1. Test MUA
echo "This is the body of email" | mail -s "This is the subject of email" "recipient@gmail.com"
  1. A Long Letter
    mail -s "This is the subject of email" "recipient@gmail.com"Enter
    This is the body of emailEnter
    This is a new lineEnter
    CTRL+D

Let's Encrypt

Installation

sudo apt update -y && sudo apt install -y python3-certbot-apache
sudo certbot --apache --agree-tos --non-interactive --email your_email_address -d your_domain_name

Renew cert

sudo letsencrypt renew

Location of cert

  • Public cert: /etc/letsencrypt/live/your_domain_name/fullchain.pem
  • Private key: /etc/letsencrypt/live/your_domain_name/privkey.pem

What are these PEM file

  • cert.pem contains the server certificate by itself.
  • chain.pem contains intermediate certificates. Some webservers like separated certficate files.
  • fullchain.pem contains cert.pem and chain.pem. Some webservers like unseparated certficate files.
  • private.pem counterpart of the server certificate

Aria2

  • You must check if RPC feature of aria2c is enabled.
apt install aria2
aria2c -v 
  • Build from src
apt install libxml2-dev libcppunit-dev autoconf automake autotools-dev autopoint libtool  pkg-config libssl-dev liblzma-dev
wget https://github.com/aria2/aria2/archive/refs/heads/master.zip
autoreconf -i
./configure ARIA2_STATIC=yes --without-gnutls --with-openssl
aria2c -d ~/Downloads --enable-rpc=true --rpc-listen-all=true