Lezi vam doma stary pc a neviete co s nim? Postavte si server!
Predpokladam ze server a pc budete mat bud pichnute v routri alebo v switchi resp. mate vytvorenu lokalnu siet. Pre pristup k serveru z vonkajsiej siete potrebujete verejnu IP.
1.) Vyber operacneho systemu
Na vybere OS pre server som ani chvilu nerozmyslal pretoze jasna odpoved bola
Ubuntu Server edition 32 bitova verzia, 64 bitova verzia Navod je stavany pre tuto distribuciu linuxu to znamena ze pri inych distribuciach sa prikazy a cesty ku suborom budu lisit.
2.) Instalacia OS
Po vypáleni OS na cd PC restartujte a nabootujte sytem z cd. Vyberte jazyk aspustite instalaciu. Samotno instalaciou sa nebudem zaoberat kedze to nieje nic tazke. Zastavim sa az pri rozdelovni pevneho disku. Pri rozdelovani disku zvolte moznost "manulne" rozdelenie disku je uz na vas akemu oddielu priradite kolko GB. Pri vybere vyberte oddiel hlavne budete potrebovat minimalne 2 oddiely to je
/ korenovy adresar(minimalne 6GB) a oddiel
swap tomu priradte dvojnasobok kapacity vasich RAM-iek .Ak vam kapacitu disku dovoluje si spravit este jeden oddiel tak to spravte. Presnejsie sa jedna o oddiel
/srv tam bude zlozka pre ftp atd. Po samotnej instalacii OS sa vas instalacia opyta aky server budete na danom PC prevadzkovat. Mozte vybrat vsetko alebo len to co naozaj potrebujete. Neskor sa da vsetko doinstalovat cize nemusite sa bat ze to potm uz nepojde. Cize pre domaci server vyberte:
OpenSSH server(budete moct ovladat server z ineho pc)
LAMP server (zide sa hlavne pri php a mysql....).Po dokonceni instalacie sa PC restratuje a nabootuje sa uz samotny OS. Po prvom spusteni sa prihlasite a server bezi

(server bezi aj ked sa neprihlasite)
3.) Zaciname s SSH
Kedze OpenSSH sme nainstalovali uz pri instalaciiOS nebude potrebne doinstalovavat baliky. Pre vzdialene pripojenie k serveru cez windows odporucam
Putty pre pripojenie k serveru cez distribuciu linux nije potrebne nic doinstalovavat v ubuntu/kubuntu napr. zadate
Kód:
ssh xxx@192.168.1.5
namiesto
xxx zadate meno uzivatela ku ktoremu sa chcete prihlasit a namiesto
192.168.1.5 zadate IP adresu vasho servera.
Po zadani hesla by sa vam mal zobrazit uz prikazovy riadok vasho server. Ked uz mame rozbehane SSH mozeme PC uz umiestnit hocikde.
3.) Firewall
Defaultny firewall v ubuntu je ufw. spustite ho prikazom
Kód:
sudo ufw enable
Firewall by sa mal spustit.Na vypnutie firewallu je prikaz
Kód:
sudo ufw disable
Ak chcete povolit niejaky port urobite tak prikazom
Kód:
sudo ufw allow cislo_portu
Port zakazete prikazom
Kód:
sudo ufw deny cislo_portu
Kedze na vasom serveri bezi ssh ktore sa pripaja cez port
22 musite tento port povolit inak vam SSH fungovat nebude. Tak isto povolte aj port
80 na ktorom bezi Apache cize webovy server a nakoniec aj port pre ftp
21. Pre vyssiu bezpecnost povolte aj porty
ftps 989, 990 a
https 443 4.) Vsftpd
Takze v tomto krku sa budeme venovat ftp-cku. Ako prve sa nainstalujeme prehliadac suborov
midnight commander Kód:
sudo apt-get install mc
po nainstalovani ho mozme spustit prikazom
Kód:
sudo mc
Teraz nainstalujeme uz samotny ftp server
Kód:
sudo apt-get install vsftpd
Po nainstalovani by vam malo vypisat nieco take
Kód:
*Starting FTP server: vsftpd [OK]
Takze teraz vam uz bezi ftp server. Konfiguracny subor ftp-cka sa nachadza v /etc/vsftpd.conf . Doporucujem si tento subor zalhovat predtym nez sa pustite do konfiguracie.Moj konfiguracny subor vyzera niejak tako
Kód:
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
#
# Run standalone? vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=YES
#
# Run standalone with IPv6?
# Like the listen parameter, except vsftpd will listen on an IPv6 socket
# instead of an IPv4 one. This parameter and the listen parameter are mutually
# exclusive.
#listen_ipv6=YES
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
#local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
anon_upload_enable=NO
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=NO
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
chown_uploads=NO
chown_username=admin
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may restrict local users to their home directories. See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
#
# Debian customization
#
# Some of vsftpd's settings don't fit the Debian filesystem layout by
# default. These settings are more Debian-friendly.
#
# This option should be the name of a directory which is empty. Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
# This option specifies the location of the RSA key to use for SSL
# encrypted connections.
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
Teraz si povieme ktory riadok co znamena. Takze:
Kód:
listen=YES
Tato volba definuje ci chceme aby vsftpd bezal ako samotny deamon alebo spolu s ostanymi sluzbami.
Kód:
anonymous_enable=NO
Povolenie prihlasenia anonymnych uzivatelov. Kedze ja to mam zakazane hodnota NO alebo zakomentovane # prihlasenie anonymnych uzivatelov nebude mozne. Ak ich chcete povolit zmente hodnotu NO na YES.
Kód:
local_enable=YES
Povolenie prihlasenia lokalnych uzivatelov.
Kód:
write_enable=YES
Povoluje zapis na server. Ak je hodnota nastavena na NO alebo je tento riadok zakomentovany nikto nebude moct na server zapisovat.
Kód:
local_umask=022
Nastavenie masky. Vychodzi port je 077 (myslim) porstrednictvom tohto riadku je mozne masku zmenit.
Kód:
anon_upload_enable=NO
Povoluje upload anonymnim uzivatelom na server.
Kód:
anon_mkdir_write_enable=NO
Umoznuje anonymnim uzivatelom vytvarat priecinky.
Kód:
xferlog_enable=YES
Informacie a stiahnutych alebo uploadovanych suboroch.
Kód:
connect_from_port_20=YES
Pripajanie sa cez port 20.
Kód:
chown_uploads=NO
Zmena vlastnika suborov.
Kód:
chown_username=admin
Vlastnikom suborov je admin.
Kód:
xferlog_file=/var/log/vsftpd.log
Logovanie sa bude ukladat do tohto suboru var/log/vsftpd.log . kludne ho mozte cestu zmenit ak chcete logovat niekde inde.
Kód:
idle_session_timeout=600
Doba (udava sa v skeundach) za ktorou v pripade necinnost sa spojenie zo serverom ukonci
Kód:
data_connection_timeout=120
Doba (tiez v sekundach) za ktorou v pripade necinnosti bude uzivatel automaticky odhlaseny.
Kód:
chroot_local_user=YES
Uzivatel je uzatvoreny v danoom priecinku pre ftp-server. V pripade zakomentovania alebo zmenenia hodnoty na hodnotu NO budete mat pristup prechadzat po celom serveri.
Po zmene konfiguracneho suboru musite ftp-server restartovat. Urobite tak prikazom
Kód:
sudo /etc/init.d/vsftpd restart
Tento clanok sa bude pravidelne rozsirovat 