20210504(화)
9:32 review
Directory Service
Authentication Service
hostname 도 꼭 설정 : 어떤 도메인대역, 내 도메인 내역이 무엇인지 확인이 필요함. ipa 명령에서 대상을 지정하지 않으면 호스트네임을 따라가게 되어있음.
/etc/hosts 도 꼭 설정 : dns값을 몰라도 찾아가는 리스트
[root@host1 ~]# echo "10.0.2.11 host1.example.net host1" >> /etc/hosts
[root@host1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.2.11 host1.example.net host1
[root@host1 ~]# yum list installed | grep ipa
--setup-dns 옵션
[root@host1 ~]# ipa-server-install --setup-dns
Directory Manager password
IPA admin password
아래 free-ipa를 통해 Openldap 서비스를 대체
Done configuring DNS key synchronization service (ipa-dnskeysyncd).
Restarting ipa-dnskeysyncd
Restarting named
Updating DNS system records
Configuring client side components
Using existing certificate '/etc/ipa/ca.crt'.
Client hostname: host1.example.net
Realm: EXAMPLE.NET
DNS Domain: example.net
IPA Server: host1.example.net
BaseDN: dc=example,dc=net
Skipping synchronizing time with NTP server.
New SSSD config will be created
Configured sudoers in /etc/nsswitch.conf
Configured /etc/sssd/sssd.conf
trying https://host1.example.net/ipa/json
…
Configured /etc/openldap/ldap.conf
Configured /etc/ssh/ssh_config
Configured /etc/ssh/sshd_config
Configuring example.net as NIS domain.
Client configuration complete.
The ipa-client-install command was successful
Next steps:
1. You must make sure these network ports are open:
TCP Ports:
* 80, 443: HTTP/HTTPS
* 389, 636: LDAP/LDAPS
* 88, 464: kerberos
* 53: bind
UDP Ports:
* 88, 464: kerberos
* 53: bind
* 123: ntp
2. You can now obtain a kerberos ticket using the command: 'kinit admin'
This ticket will allow you to use the IPA tools (e.g., ipa user-add)
and the web user interface.
conf 파일과 각각의 포트에 대한 방화벽체크
kinit admin 명령어 체크
방화벽 : freeipa-ldap, freeipa-ldaps, dns
[root@host1 ~]# firewall-cmd --add-service=dns
success
[root@host1 ~]# klist
Ticket cache: KEYRING:persistent:0:0
Default principal: admin@EXAMPLE.NET
Valid starting Expires Service principal
05/04/2021 10:46:51 05/05/2021 10:46:49 krbtgt/EXAMPLE.NET@EXAMPLE.NET
[root@host1 ~]# ipa user-add
[root@host1 ~]# ipa user-find
--------------
1 user matched
--------------
User login: admin
Last name: Administrator
Home directory: /home/admin
Login shell: /bin/bash
Principal alias: admin@EXAMPLE.NET
UID: 1010200000
GID: 1010200000
Account disabled: False
----------------------------
Number of entries returned 1
----------------------------
[root@host1 ~]# id admin
uid=1010200000(admin) gid=1010200000(admins) groups=1010200000(admins)
id 명령어로 조회가능하며, 홈디렉터리를 별도로 갖는다.
chown을 통해 uid(admin):gid(admins)를 통해 홈디렉터리의 권한을 변경해준다.
[root@host1 ~]# ipa config-mod --help
Modify configuration options.
Options:
…
-h, --help show this help message and exit
--maxusername=INT Maximum username length
--homedirectory=STR Default location of home directories
--defaultshell=STR Default shell for new users
--defaultgroup=STR Default group for new users
…
[root@host1 ~]# ipa config-mod --defaultshell=/bin/bash
Maximum username length: 32
Home directory base: /home
Default shell: /bin/bash
인증서 : /etc/ipa
end of server configuraiton (/etc/openldap)
================
클라이언트 설정
[root@host2 ~]# yum install ipa-client
[root@host2 ~]# nmcli con mod enp0s3 ipv4.dns 10.0.2.11 → 호스트의 dns로 설정
[root@host2 ~]# nmcli con up enp0s3
[root@host2 ~]# ipa-client-install --mkhomedir
Discovery was successful!
Client hostname: host2.example.net
Realm: EXAMPLE.NET
DNS Domain: example.net
IPA Server: host1.example.net
BaseDN: dc=example,dc=net
=================
사용자 생성 및 호스트 접속확인
①서버에서 유저 생성 : ipa user-add (ipa user-mod)
②클라이언트에서 접속 유저확인 : getent
③클라이언트에서 접속 테스트 : localhost, host1.example.net
(mkhomdir 의 작동여부도 같이 테스트)
kinit : 어드민 인증
klist : 인증작업 티켓 발급이 되었을때 목록 확인
[root@host1 ~]# ipa user-add testuser01 --password
[root@host1 ~]# ipa user-mod testuser01
[root@host2 ~]# getent passwd testuser01
[root@host2 ~]# ssh testuser01@localhost → 자기 자신에게 연결
[root@host2 ~]# pwd
[root@host2 ~]# id
[root@host2 ~]# ssh testuser01@host1.example.net → 1번호스트에게 연결
Password:
Could not chdir to home directory /home/testuser01: No such file or directory
-bash-4.2$ pwd
/
홈디렉터리 미생성 --mkhomdir 옵션의 유무
=================
kerberos P960 서버설치~
/etc/sssd/sssd.conf
/etc/krb5.conf
/etc/krb5.keytab
[root@host1 ~]# vim /var/kerberos/krb5kdc/kdc.conf
[root@host1 sssd]# yum list installed krb5-server krb5-workstation pam_krb5
krb5-server KDC 구축 서버
krb5-workstation 클라이언트가 설치해야하는 패키지
시간 동기화 체크 : 인증서비스는 시간일치 등의 시간서비스가 중요
[root@host1 ~]# systemctl status ntpd : 7버전부터는 기본 서비스가 아님
[root@host1 ~]# systemctl status chronyd : ntpd를 대체
[root@host1 ~]# ntpq -p
[root@host1 ~]# ipa service-add
[root@host1 ~]# ipa service-add service/host-FQDN@realm^C
[root@host1 ~]# ipa service-add nfs/host1.example.net@EXAMPLE.NET
[root@host1 ~]# ipa service-add samba/host1.example.net@EXAMPLE.NET
[root@host1 ~]# ipa service-show samba/host1.example.net: 특정 서비스 지정
[root@host1 ~]# ipa service-find : 등록된 전체 서비스 출력가능
=================
NFS P671 파일서버 (파일공유)
DAS : Direct Access Storage
NAS : Network Attached Storage (NFS 등)
SAN :
/etc/exports
/etc/exports.d/
vim /etc/exports
# DIRECTORY TARGET(OPTION)
/shares host2.example.net(rw,sync)
# /server_share 192.168.80.0/24(rw,sync,no_root_squash,no_all_squash)
# *.example.net
# *
# 10.0.2.12/32(ro,sync)
ro : read only
sync : 동기화 방식
root_squash : nfsnobody 유저로 매핑되어 인식
no_root_squah : root로 접근시 root권한을 부여. 보안적으로 리스크가 있을 수 있음
임베디드 시스템(IoT 등) 굳이 모든 데이터를 직접가질 필요 없는 경우, 사이즈를 줄이기 위해
no_all_squash : 각 사용자의 권한을 공유디렉터리에서도 허용함
# mkdir shares
# exportfs -r
# systemctl status nfs-server
# systemctl status RPF
# firewall-cmd --add-service=nfs
# firewall-cmd --add-service=mountd : 보안적으로는 서비스를 사용하지 않는편이 낫다.
# firewall-cmd --add-service=rpc-bind
# firewall-cmd --add-port=46692/tcp
NFS 는 수동방식( 수동, /etc/fstab ) 자동방식 (autofs) 세가지 방법이 있다.
NFS 네트워크 연결이기 때문에 항상 연결되어있으면 부담이 될 수 있고, autofs 를 통해 시간이 지나면 자동해제가 되도록 사용할 수 있다.
END OF SERVER CONFIGURATION
======================
클라이언트
#mount -t -o SERVER:/DIR <MOUNTPOINT>
-t : filesystem type
-o :
[root@host2 ~]# mount -t nfs -o rw,sync,v4.2 → 버전 등을 설정가능
[root@host2 ~]# mount -t nfs -o sec=none,sys,krb5,krb5i,krb5p → 인증방식 설정 (기본값 sys) : 서버에도 세팅 필요
krb5 : 단순인증
krb5i : 인증 + 무결성 보장
krb5p : 모든 통신데이터를 암호화해서 통신 (성능에 다소 영향)
[root@host2 ~]# mount -t nfs -o rw,sync 10.0.2.11:/shares /mnt
[root@host2 ~]# vim /etc/fstab
10.0.2.11:/shares /mnt nfs rw,sync 0 0 → TARGET, MOUNT_POINT, FILE SYSTEM, OPTION …
=======================
autofs
패키지 설치 (이미 설치되어있는경우 있음)
# yum install autofs
설정파일 생성 : xxxx.autofs / auto.xxxx 양식을 꼭 지킬것.
# vim /etc/auto.master.d/test.autofs
# Mount Point position mappingFile
/- /etc/auto.test : 직접 매핑
/mnt /etc/auto.test : 간접 매핑
# vim /etc/auto.test
파일시스템, 옵션, 서버
/mnt/nfs -rw,sync 10.0.2.11:/shares : 직접 매핑
nfs -rw,sync 10.0.2.11:/shares : 간접 매핑
# systemctl start autofs
/mnt/nfs
# vim /etc/exports
/nfs/docs 10.0.2.11 (rw,sync)
/nfs/music 10.0.2.11 (rw,sync)
/nfs/movie 10.0.2.11 (rw,sync)
동시 공유시,
vim /etc/auto.test
* -rw,sync 10.0.2.11:/nfs/& → nfs하위 모든 폴더에대해 공유, 마운트