NAS для хомяков по бюджету. Часть 2 — Debian

Первоначально при установке Debian ругнулся на необходимость non-free пакета firmware-realtek для сетевой карты, оный был скачан и скормлен инсталлеру на usb флешке. Разметка диска автоматическая, все разделы в одной фс. С UEFI проблем не возникло.
Установка всех необходимых программ:
apt-get install sudo mc net-tools parted openssh-server samba transmission-daemon minidlna
Настройка sudo:
nano /etc/sudoers
реклама
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
maks ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
Конфигурация openssh:
Изменяем:
LoginGraceTime 1m
PermitRootLogin no
PubkeyAuthentication yes
Получилось чтото вроде:
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
LoginGraceTime 1m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
PubkeyAuthentication yes
# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile %h/.ssh/authorized_keys
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
# override default of no subsystems
Subsystem sftp /usr/lib/openssh/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
После перезапускаем openssh командой:
реклама
service sshd restart
Выходим из под рута и все дальнейшие манипуляции спокойно проводим из PuTTY:
после первого запуска в hostname прописываем наш ip (192.168.1.34) и порт, в поле Saved sessions вводим название профиля и жмём Save
Подкорректируем ярлык запуска: добавив связку login@SRVNAME:
"C:\Program Files\PuTTY\putty.exe" maks@Server
Теперь призапуске с ярлыка достаточно будет ввести пароль и ты внутри :)
У нас имеется всё ещё не размеченный винчестер для медиа, займёмся теперь им:
sudo parted /dev/sdb
mklabel gpt
mkpart Drive 0% 100%
quit
mkfs.ext4 /dev/sdb1
Мы разметили диск от начала до конца и создали на нём фс ext4. Самое время задуматься об автомаунте диска:
ls -l /dev/disk/by-uuid
mkdir /home/maks/drive
chmod 777 /home/maks/drive
sudo nano /etc/fstab
добавим строчку для нашего раздела:
реклама
UUID=8c47d107-cc37-4ab2-8e95-70f508254b3d /home/maks/drive ext4 defaults 0 2
Сохраняем изменения и подключаем всё что прописано в fstab:
sudo mount -a
В настройке samba вообще не заморачивался вылавливанием нужных строк, посему:
sudo nano /etc/samba/smb.conf
ALT+T (очищаем содержимое) и забиваю следующий конфиг:
[global]
workgroup = WORKGROUP
netbios name = SERVER
security = user
map to guest = Bad Password
guest ok = yes
null passwords = Yes
dos charset = CP866
unix charset = utf8
[Drive]
path = /home/maks/drive
public = yes
writable = yes
read only = no
hide files = /$RECYCLE.BIN/desktop.ini/lost+found/Thumbs.db/~*/
Перезапускаем samba:
sudo service smbd restart
настройка Transmission
реклама
sudo service transmission-daemon stop
sudo nano /etc/transmission-daemon/settings.json
Изменяем следующие настройки:
"download-dir": "/home/maks/drive/Загрузки",
"port-forwarding-enabled": true,
"rpc-authentication-required": true,
"rpc-bind-address": "192.168.1.34",
"rpc-enabled": true,
"rpc-password": "Password",
"rpc-port": 9091,
"rpc-username": "maks",
"rpc-whitelist": "127.0.0.1,192.168.1.*",
"rpc-whitelist-enabled": true,
"umask": 0,
и получаем:
{
"alt-speed-down": 50,
"alt-speed-enabled": false,
"alt-speed-time-begin": 540,
"alt-speed-time-day": 127,
"alt-speed-time-enabled": false,
"alt-speed-time-end": 1020,
"alt-speed-up": 50,
"bind-address-ipv4": "0.0.0.0",
"bind-address-ipv6": "::",
"blocklist-enabled": false,
"blocklist-url": "http://www.example.com/blocklist",
"cache-size-mb": 4,
"dht-enabled": true,
"download-dir": "/home/maks/drive/Загрузки",
"download-limit": 100,
"download-limit-enabled": 0,
"download-queue-enabled": true,
"download-queue-size": 5,
"encryption": 1,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "/var/lib/transmission-daemon/Downloads",
"incomplete-dir-enabled": false,
"lpd-enabled": false,
"max-peers-global": 200,
"message-level": 1,
"peer-congestion-algorithm": "",
"peer-id-ttl-hours": 6,
"peer-limit-global": 200,
"peer-limit-per-torrent": 50,
"peer-port": 51413,
"peer-port-random-high": 65535,
"peer-port-random-low": 49152,
"peer-port-random-on-start": false,
"peer-socket-tos": "default",
"pex-enabled": true,
"port-forwarding-enabled": true,
"preallocation": 1,
"prefetch-enabled": true,
"queue-stalled-enabled": true,
"queue-stalled-minutes": 30,
"ratio-limit": 2,
"ratio-limit-enabled": false,
"rename-partial-files": true,
"rpc-authentication-required": true,
"rpc-bind-address": "192.168.1.34",
"rpc-enabled": true,
"rpc-password": "PASSWORD",
"rpc-port": 9091,
"rpc-url": "/transmission/",
"rpc-username": "maks",
"rpc-whitelist": "127.0.0.1,192.168.1.*",
"rpc-whitelist-enabled": true,
"scrape-paused-torrents-enabled": true,
"script-torrent-done-enabled": false,
"script-torrent-done-filename": "",
"seed-queue-enabled": false,
"seed-queue-size": 10,
"speed-limit-down": 100,
"speed-limit-down-enabled": false,
"speed-limit-up": 100,
"speed-limit-up-enabled": false,
"start-added-torrents": true,
"trash-original-torrent-files": false,
"umask": 0,
"upload-limit": 100,
"upload-limit-enabled": 0,
"upload-slots-per-torrent": 14,
"utp-enabled": true
}
sudo service transmission-daemon start
Финальный штрих:
mkdir /home/maks/drive/.minidlna
chmod 777 /home/maks/drive/.minidlna
sudo nano /etc/minidlna.conf
изменяем:
media_dir=V,/home/maks/drive/Фильмы
db_dir=/home/maks/drive/.minidlna
friendly_name=Media
Далее перезапускаем сервер:
sudo service minidlna stop
sudo service minidlna start
Собственно и всё. Теперь можно на всякий случай перезапустить сервер
sudo shutdown -r now
Дабы убедиться что при перезагрузке ничего не слетит и всё по прежнему будет работать.
Лента материалов
Соблюдение Правил конференции строго обязательно!
Флуд, флейм и оффтоп преследуются по всей строгости закона!
Комментарии, содержащие оскорбления, нецензурные выражения (в т.ч. замаскированный мат), экстремистские высказывания, рекламу и спам, удаляются независимо от содержимого, а к их авторам могут применяться меры вплоть до запрета написания комментариев и, в случае написания комментария через социальные сети, жалобы в администрацию данной сети.
Сейчас обсуждают