NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here.
Enter current password for root (enter for none): //패스워드 설정을 안했으므로 그냥 Enter OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation.
Set root password? [Y/n] y New password: //새로운 패스워드 입력 Re-enter new password: //새로운 패스워드 다시 입력 Password updated successfully! Reloading privilege tables.. ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
Remove anonymous users? [Y/n] y ... Success!
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y ... Success!
By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.
Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
Reload privilege tables now? [Y/n] y ... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB installation should now be secure.
[genius@localhost ~]$ sudo mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 15 Server version: 5.5.64-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> MariaDB [(none)]> MariaDB [(none)]> create database `ccnet-db` character set = 'utf8mb4'; Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create database `seafile-db` character set = 'utf8mb4'; Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create database `seahub-db` character set = 'utf8mb4'; Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> MariaDB [(none)]> create user 'seafile'@'localhost' identified by 'p@ssw0rd'; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> MariaDB [(none)]> GRANT ALL PRIVILEGES ON `ccnet-db`.* to `seafile`@localhost; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON `seafile-db`.* to `seafile`@localhost; Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON `seahub-db`.* to `seafile`@localhost; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> Ctrl-C -- exit! Aborted
# mysql -u root -p : Mariadb 접속, 아까 생성한 root 계정 패스워드 입력
# create database `ccnet-db` character set = 'utf8mb4'; : 데이터베이스 생성 # create database `seafile-db` character set = 'utf8mb4'; : 데이터베이스 생성 # create database `seahub-db` character set = 'utf8mb4'; : 데이터베이스 생성 # create user 'seafile'@'localhost' identified by '새로운 패스워드'; : mariadb의 seafile계정이 사용할 패스워드 # GRANT ALL PRIVILEGES ON `ccnet-db`.* to `seafile`@localhost; : 권한설정 # GRANT ALL PRIVILEGES ON `seafile-db`.* to `seafile`@localhost;: 권한설정 # GRANT ALL PRIVILEGES ON `seahub-db`.* to `seafile`@localhost;: 권한설정
[genius@localhost ~]$ sudo useradd -m -d /home/seafile seafile [genius@localhost ~]$ sudo passwd seafile seafile 사용자의 비밀 번호 변경 중 새 암호: 잘못된 암호: 암호에 어떤 형식으로 사용자 이름이 포함되어 있습니다 새 암호 재입력: passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.
[genius@localhost ~]$ su - seafile 암호: [seafile@localhost ~]$ cd ~ [seafile@localhost ~]$ pwd /home/seafile
# useradd -m -d /home/seafile seafile : seafiel 계정 생성
[seafile@localhost ~]$ cd seafile-server-7.0.5/ [seafile@localhost seafile-server-7.0.5]$ ./setup-seafile-mysql.sh Checking python on this machine ... Checking python module: python-mysqldb ... Done.
----------------------------------------------------------------- This script will guide you to setup your seafile server using MySQL. Make sure you have read seafile server manual at
Which port do you want to use for the seafile fileserver? [ default "8082" ] 8082
------------------------------------------------------- Please choose a way to initialize seafile databases: -------------------------------------------------------
[1] Create new ccnet/seafile/seahub databases [2] Use existing ccnet/seafile/seahub databases
[ 1 or 2 ] 2
What is the host of mysql server? [ default "localhost" ] 엔터
What is the port of mysql server? [ default "3306" ] 엔터
Which mysql user to use for seafile? [ mysql user for seafile ] 엔터
What is the password for mysql user "seafile"? [ password for seafile ] mariadb의 seafile 패스워드(3번 참조)
verifying password of user seafile ... done
Enter the existing database name for ccnet: [ ccnet database ] ccnet-db
verifying user "seafile" access to database ccnet-db ... done
Enter the existing database name for seafile: [ seafile database ] seafile-db
verifying user "seafile" access to database seafile-db ... done
Enter the existing database name for seahub: [ seahub database ] seahub-db
verifying user "seafile" access to database seahub-db ... done
--------------------------------- This is your configuration ---------------------------------
server name: ㅁㅁㅁㅁㅁ server ip/domain: 192.168.xxx.xxx
seafile data dir: /....../seafile-data fileserver port: 8082
--------------------------------- Press ENTER to continue, or Ctrl-C to abort ---------------------------------
Generating ccnet configuration ...
done Successly create configuration dir /home/seafile/ccnet. Generating seafile configuration ...
Checking python on this machine ... Checking python module: python-mysqldb ... Done.
----------------------------------------------------------------- This script will guide you to setup your seafile server using MySQL. Make sure you have read seafile server manual at
LC_ALL is not set in ENV, set to en_US.UTF-8 Starting seahub at port 8000 ...
---------------------------------------- It's the first time you start the seafile server. Now let's create the admin account ----------------------------------------
What is the email for the admin account? [ admin email ] 메일주소
What is the password for the admin account? [ admin password ] 새로운패스워드입력
Enter the password again: [ admin password again ] 새로운패스워드입력
---------------------------------------- Successfully created seafile admin ----------------------------------------
[genius@localhost system]$ sudo systemctl enable seafile Created symlink from /etc/systemd/system/multi-user.target.wants/seafile.service to /usr/lib/systemd/system/seafile.service. [genius@localhost system]$ sudo systemctl enable seahub Created symlink from /etc/systemd/system/multi-user.target.wants/seahub.service to /usr/lib/systemd/system/seahub.service.
...... smbuser:x:1001:100::/home/smbuser:/bin/bash [genius@localhost ~]$ sudo passwd smbuser smbuser 사용자의 비밀 번호 변경 중 새 암호: 잘못된 암호: 암호는 8 개의 문자 보다 짧습니다 새 암호 재입력: passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.
# useradd -Mn smbuser : smbuser라는 계정을 생성
-Mn : samba 접속시에 사용할 계정이므로 home 디렉토리 생성안함. 그룹도 생성하지 않음
# passwd smbuser : 패스워드 생성
2. smaba 설치 및 계정 등록
[genius@localhost ~]$ sudo yum install samba
..........
[genius@localhost ~]$ sudo smbpasswd -a smbuser New SMB password: Retype new SMB password: Added user smbuser.
# smbpasswd -a smbuser : samba에 사용될 계정 패스워드 설정(1번에서 만든 계정 패스워드와는 다름)
3. smb.conf 수정
[genius@localhost ~]$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_20191128 [genius@localhost ~]$ sudo vi /etc/samba/smb.conf [global] workgroup = SAMBA security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw
[public] comment = Tao Nas public directory path = /data/public write list = smbuser create mask = 0664 directory mask = 0775 writable = yes printable = no public = no
[global] workgroup = SAMBA security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw
[public] comment = Tao Nas public directory path = /data/public : 여기가 제일 중요 공유할 디렉토리 write list = smbuser : 접속할 계정 1번에서 생성한 계정 등록 create mask = 0664 directory mask = 0775 writable = yes printable = no public = no
이렇게 수정. 다른 부분은 딱히 필요하지 않으므로 다 삭제해도 무방하고 남겨도 무방함.
4. firewall 등록
[genius@localhost ~]$ sudo firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: enp3s0 sources: services: dhcpv6-client ssh ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
[genius@localhost ~]$ cd /data [genius@localhost data]$ ls public [genius@localhost data]$ sudo chown -R smbuser.100 ./public/ [sudo] genius의 암호: [genius@localhost data]$ ll 합계 0 drwxr-xr-x. 4 smbuser users 31 11월 27 20:46 public
# cd /data : /data 디렉토리로 이동
# sudo chown -R smbuser.100 ./public/ : ./public 및 서브디렉토리까지.. 사용자 및 그룹 변경
이제 윈도우에서 다시 접속해서... 디렉토리(폴더)와 파일을 생성해보자..
그리고 권한 맞게 생서되는지 확인하자.
[genius@localhost data]$ cd public/ [genius@localhost public]$ ll -rw-rw-r--. 1 smbuser users 0 11월 28 21:54 새 텍스트 문서.txt drwxrwxr-x. 2 smbuser users 6 11월 28 21:53 새 폴더