일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- firewalld
- yum
- Kubernetes
- chatGPT
- docker image
- 리다이렉션
- 랜카드인식불량
- docker network
- pvcreate
- nmcli
- swapon
- 같은폴더
- ssh
- journalctl
- vgcreate
- M365필터
- MSBing
- HTTPD
- lvcreate
- ansible
- docker
- vagrant kubernetes
- permission
- tar
- 프로세스
- mount
- 날짜변경
- newbingai
- 엑셀파일명변경
- chmod
- Today
- Total
becool
20210506 (목) 본문
09:33
P583 FTP서버 (File Transfer Protocol)
Pure FTP, VsFTP(Very Secure FTP), ProFTP 등
ssh 와 마찬가지로 암호화하여 주고 받을 수 있음.
SSL 의 개선버전 TLS (http, https 와 같은 맥락)
FTP는 NFS와 같이 특정 디렉터리만 고정되어 공유하는 것이 아니라 권한설정을 통해 원하는 디렉터리를 탐색하고 다운로드 할 수 있게 함.
기존FTP
평문을 주고 받고 방화벽 설정 조건 등 다소 보안상 취약함.
ftp서버가 사용하는 두 가지 포트 (클라이언트는 모드에 따라 다름)
20번 포트 : Data 포트
21번 포트 : Command 포트
Passive모드를 통하여 사용할 포트를 제한적으로 설정하고 그에 따른 방화벽 설정을 맞추어야함.
VsFTP
SSL/TLS 사용으로 보안 이슈 보완
[root@host1 etc]# yum install vsftpd
[root@host1 etc]# systemctl start vsftpd (필요시 start 대신 enable)
[root@host1 ~]# ss -ntulp |grep :21
tcp LISTEN 0 32 [::]:21 [::]:* users:(("vsftpd",pid=3476,fd=4))
[root@host1 ~]# netstat -tulpn |grep :21 (netstat = ss 비슷한 명령어)
tcp6 0 0 :::21 :::* LISTEN 3476/vsftpd
[root@host1 ~]# firewall-cmd --add-service=ftp (--permanent)
success
[root@host1 ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3 enp0s8
sources:
services: dhcpv6-client ftp ssh
[root@host1 ~]# vim /etc/vsftpd/vsftpd.conf
anonymous_enable=YES : 임의의 사용자 허가 여부
local_enable=YES : SELinux가 활성화된 경우 "SE의 부울 ftp_home_dir"도 체크
local_umask=022 :
write_enable=YES :
# anon_upload_enable=YES : SELinux가 활성화된 경우 " SE의 부울 allow_ftpd_anon_wirte, allow_ftp_full_access" 체크
# anon_mkdir_wirte_enable=YES
# chown_uploads=YES 소유권을 설정하면서 업로드 가능여부
# chown_username=ftp ftp사용자 이름 지정
# anon_umask=077 임의의 사용자 umask
# ascii_upload_enable=YES (ascii 방식 비활성화 시 binary)
# ascii_download_enable=YES (윈도우 - 리눅스 간 파일 전송 시 두가지 YES라고 설정되어야 함)
# chroot_local_user=YES ( chroot 환경을 ftp를 통해 사용하고 싶으면 세가지 설정을 사용함)
# chroot_list_enable=YES
# chroot_list_file=/etc/vsftpd/chroot_list
# ls_recurse_enable=YES ( 리커시브 적용 )
listen=NO (스탠드얼론 허용여부)
listen_ipv6=YES (ipv6에 대해 허용여부)
use_localtime=YES (로컬타임 사용여부, ntp동기화가 best이지만 이 옵션도 사용가능)
==========================================
클라이언트
[root@host2 ~]# yum install lftp
[root@host2 ~]# lftp 10.0.2.11 (anonymous)
lftp 10.0.2.11:/> pwd
ftp://10.0.2.11/
get : 다운로드
put : 업로드
lftp 10.0.2.11:/> get hosts
158 bytes transferred
[user@host2 ~]$ lftp user@10.0.2.11 (user)
Password:
lftp user@10.0.2.11:~> ls -l
===========================================
기타 서비스 설정
P592유저 접근 제한
[root@host1 ftp]# vim /etc/vsftpd/ftpusers
유저 접근 제어리스트를 파일로 설정가능
차단시, 패스워드를 통한 접속은 되나 명령어사용불가
lftp user@10.0.2.11:~> ls -l
ls: Login failed: 530 Login incorrect.
[root@host1 ftp]# vim /etc/hosts.allow
ftp서버 뿐만 아니라 다양한 네트워크서비스에 영향을 주는 파일로써 allow or deny connections 설정가능
P600 연결제한 (timeout)
P605 로그설정 /etc/vsftpd/vsftpd.conf
syslog_enable=YES 로그메시지 기록 활성화
/var/log/vsftpd.log 생성
P608 패시브모드 설정 /etc/vsftpd/vsftpd.conf
pasv_enable=YES (주석에 없음, 즉 기본값은 액티브 모드)
pasv_max_port=61010
pasv_min_port=61000
systemctl restart vsftpd
===========================================
보안설정 SFTP, TLS 인증서
SFTP
yum list installed openssh-server
/etc/ssh/sshd_config
#Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp
윗줄 주석 처리 후 아랫줄 활성화
sftp user@10.0.2.11
The authenticity of host '10.0.2.11 (10.0.2.11)' can't be established.
ECDSA key fingerprint is SHA256:F/j1gQuukvv53OfFcyEbFv/uJPovGz3fT0LnnQK1+XE.
ECDSA key fingerprint is MD5:54:f8:fa:eb:63:d3:18:62:da:da:c9:33:42:de:62:57.
Are you sure you want to continue connecting (yes/no)?
ssh와 마찬가지 형태로 진행됨
Open SSL/TLS 인증서 방식
/etc/pki/tls/cert
[root@host1 certs]# openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout vsftpd.pem -out vsftpd.pem
인증서 생성 후 권한 설정 필수 : 개인키이면서 인증서이므로 일반사용자 접근을 차단
[root@host1 certs]# chmod 400 vsftpd.pem
[root@host1 certs]# chown root:root vsftpd.pem
[root@host1 certs]# vim /etc/vsftpd/vsftpd.conf 를 통해 위 인증서를 설정 (P614 1~11)
rsa_cert_file=/etc/pki/tls/certs/vsftpd.pem
rsa_private_key_file=/etc/pki/tls/certs/vsftpd.pem
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
ssl_ciphers=HIGH (128비트 이상 설정시 HIGH)
=====================================
P623 SAMBA SERVICE
samba
samba-clinet : smbclient 명령어 도구 서버쪽에서 사용자 설정때 필요하므로 서버도 패키지 설치가 필요할 수 있음.
samba-common :
[root@host1 ~]# yum install samba
[root@host1 ~]# systemctl start smb
[root@host1 ~]# systemctl enable smb
[root@host1 ~]# systemctl start nmb
[root@host1 ~]# systemctl enable nmb
[root@host1 ~]# firewall-cmd --add-service=samba --permanent
success
[root@host1 ~]# firewall-cmd --reload
success
[root@host1 /]# mkdir -pv /samba_share
[root@host1 /]# semanage fcontext -at samba_share_t '/samba_share(/.*)?'
[root@host1 /]# restorecon -Rv /samba_share/
restorecon reset /samba_share context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:samba_share_t:s0
[root@host1 /]# ls -ldZ /samba_share/
drwxr-xr-x. root root unconfined_u:object_r:samba_share_t:s0 /samba_share/
[root@host1 /]# touch /samba_share/windows_data : 공유할 파일 샘플
[root@host1 /]# ls -l /samba_share/
[root@host1 /]# useradd -s /sbin/nologin win1
[root@host1 /]# passwd win1
[root@host1 /]# useradd -s /sbin/nologin win2
[root@host1 /]# passwd win2
[root@host1 /]# smbpasswd -a win1
New SMB password:
Retype new SMB password:
Added user win1.
[root@host1 /]# pdbedit -a win2
[root@host1 /]# pdbedit -L
win1:1004:
win2:1005:
[root@host1 /]# groupadd -r ipadmins
[root@host1 /]# usermod -G ipadmins win1
[root@host1 /]# id win1
uid=1004(win1) gid=1004(win1) groups=1004(win1),981(ipadmins)
[root@host1 /]# ls -ld /samba_share/
drwxr-xr-x. 2 root root 26 May 7 17:09 /samba_share/
[root@host1 /]# chmod -R 777 /samba_share/
[root@host1 /]# ls -ld /samba_share/
drwxrwxrwx. 2 root root 26 May 7 17:09 /samba_share/
[root@host1 /]# vim /etc/samba/smb.conf
[신규 세션]
path
valid users
write list
read only
browseable
[root@host1 /]# testparm
[smb_share] → smb.conf 내용과 확인
path = /samba_share
valid users = @ipadmins win1 win2
write list = win2
[root@host1 /]# systemctl restart smb nmb
[root@host1 /]# yum install cifs-utils
[root@host1 /]# mount -t cifs -o username=win1 //10.0.2.11/smb_share /mnt
Password for win1@//10.0.2.11/smb_share: ****
[root@host1 /]# pdbedit -a root
new password:
retype new password:
==================서버 세팅 완료==================
완료 후 컨픽 문법 체크 : testparm
서버 컨텍스트 권한 리체크
[root@host1 shares]# semanage fcontext -a -t samba_share_t '/samba/shares(/.*)?'
[root@host1 shares]# restorecon -RFv /samba/shares
실습시 체크 옵션
guest ok
wirte list
==============================
P635 클라이언트 설정
[root@host2 mnt]# yum install samba cifs-utils -y
[root@host2 mnt]# yum install samba-client
[root@host2 mnt]# mount -t cifs -o username=win1 //10.0.2.11/smb_share /mnt
Password for win1@//10.0.2.11/smb_share: ****
[root@host2 ~]# mount -t cifs -o username=smbuser01,password=XX credentials=FILE //SERVER/SECTION MOUNT_POINT→ //10.0.2.11/shares /mnt
→ username과 password를 직접 타이핑하면 보안상의 문제가 야기될 수 있으므로
크레덴셜 옵션을 통해 파일 위치를 지정 (파일 내에는 해당 정보들이 들어가 있어야함.
※ //SERVER/SECTION : SECTION → conf의 [] 어느 섹션의 PATH를 참고할지를 지정하여주는 것임.
※ vim cred (credentials=FILE)
username =
password =
domain=SAMBA
chmod 700 cred
[root@host2 ~]# cifscreds
Usage:
cifscreds add [-u username] [-d] <host|domain>
cifscreds clear [-u username] [-d] <host|domain>
cifscreds clearall
cifscreds update [-u username] [-d] <host|domain>
[root@host2 ~]# cifscreds add -u smbuser01 10.0.2.11^C
위와같이 cifscreds 명령어를 통해 사용자를 추가했다면 마운트 시, 옵션 추가
: credentials=FILE,multiuser,sec=ntlmssp (멀티유저, 인증방식 두가지 옵션을 추가해야함)
==============================
/etc/samba/smb.conf
[global]
workgroup = workgroup : 윈도우의 공유그룹이라는 개념을 사용하게 하기 위함.
sercurity = user : 사용자기반의 인증방식 접근제어를 통상적으로사용함.
passdb backend = tdbsam : 사용자 정보를 저장할 데이터베이스 백엔드를 뜻하며, tdbsam 또는 ldapsam 사용가능
[homes]
comment = Home Directories
valid users = %S, %D%w%S : 접근할수 있는 대상 설정 (사용자 이름 입력가능)
browseable = No : YES로 하면 클라이언트가 공유영역에 대한 검색 가능
read only = No : yes 읽기전용 no 읽기 쓰기
inherit acls = Yes :
# writable : read only 의 반대개념 (YES, NO)
[printers]
comment = All Printers
path = /var/tmp : 경로
printable = Yes
create mask = 0600
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers : 경로
write list = @printadmin root : @그룹, 사용자 를 지칭해서 쓰기권한을 각각 부여할 수 있음.
force group = @printadmin
create mask = 0664
directory mask = 0775
[shares]
path = /shares : 실제 공유할 경로
readonly = YES
write list = user
guest ok = yes : vsftpd 의 anonymous 허용과 비슷한 맥락
valid users = @smbgroup 접근할 수 있는 사용자들 지정
autofs
smb -fstype=cifs,cred/user,pass+multiuser,sec=ntlmssp …
파일시스템 옵션을 추가해야하며
나머지는 기존 mount와 동일함
//SERVER/section
→ autofs 사용시에는 콜론 필요함 ( ://10.0.2.11/section )
==============================
'linux' 카테고리의 다른 글
20210616 (수) dns, web서비스 (0) | 2021.06.16 |
---|---|
20210507(금) (0) | 2021.05.07 |
20210504(화) (0) | 2021.05.04 |
20210503 (월) (0) | 2021.05.03 |
20210430 (금) (0) | 2021.04.30 |