becool

20210428 (수) 본문

linux

20210428 (수)

gusalstm 2021. 4. 28. 16:54
반응형

09:33 review 

 

nmcli

[root@host1 ~]# nmcli con add con-name net1 type ethernet ifname enp0s8 ip4 192.168.56.10/24 gw4 192.168.56.1

[root@host1 ~]# ifconfig enp0s3

[root@host1 ~]# ip address show → linux 버전에 따라(최소설치 등) ifconfig 대체 명령어

[root@host1 ~]# ip address show enp0s3

 

/etc/sysconfig/network-scripts/

[root@host1 network-scripts]# ls -l ifcfg-*
-rw-r--r--. 1 root root 355 Apr 27 14:47 ifcfg-enp0s3
-rw-r--r--. 1 root root 342 Apr 27 14:56 ifcfg-enp0s8
-rw-r--r--. 1 root root 254 May 22  2020 ifcfg-lo
-rw-r--r--. 1 root root 332 Apr 28 09:40 ifcfg-net1
-rw-r--r--. 1 root root 280 Apr 28 09:38 ifcfg-test

 

/etc/resolv.conf

nameserver 8.8.8.8 (dns서버)

 

hostname 

 - 네트워크 상에서 각각의 컴퓨터를 구별하기 위한 이름

 transient hostname

 static hostname

 pretty hostname

 

# hostname NAME → 재부팅 후 적용안됨

/etc/hostname → 파일 편집, 재부팅 시에도 적용

[root@host1 network-scripts]# hostnamectl set-hostname server.example.com → /etc/hostname 에 즉시 반영됨

[root@host1 network-scripts]# hostnamectl set-hostname "Gildong's Computer" --pretty
[root@host1 network-scripts]# hostnamectl 
   Static hostname: server.example.com
   Pretty hostname: Gildong's Computer

 

=================================

 

[user@host2 ~]$ ssh 192.168.56.11

 → 유저명 없이 IP로그인을하면 현재사용자와 동일한 uid 로 접속을 시도한다.

 

[user@host2 ~]$ ssh -X root@192.168.56.11
[root@host1 ~]# gedit /etc/resolv.conf 

 -X 옵션으로 gedit 실행

 

[user@host2 ~]$ ssh root@192.168.56.11
[root@host1 ~]# gedit /etc/resolv.conf 

(gedit:3853): Gtk-WARNING **: 10:58:19.316: cannot open display: 

  -X옵션이 없어서 실행불가

 

/etc/ssh/sshd_config

     17 #Port 22    → 포트 22
     18 #AddressFamily any
     19 #ListenAddress 0.0.0.0  → 서비스 대기 IP 주소

     …

     22 HostKey /etc/ssh/ssh_host_rsa_key  → 호스트키
     23 #HostKey /etc/ssh/ssh_host_dsa_key
     24 HostKey /etc/ssh/ssh_host_ecdsa_key
     25 HostKey /etc/ssh/ssh_host_ed25519_key

     …

     30 # Logging
     31 #SyslogFacility AUTH
     32 SyslogFacility AUTHPRIV
     33 #LogLevel INFO
     34 

     35 # Authentication:
     36 
     37 #LoginGraceTime 2m
     38 #PermitRootLogin yes  (without-password - 패스워드를 통한 로그인은 불가하도록 조건설정)
     39 #StrictModes yes
     40 #MaxAuthTries 6
     41 #MaxSessions 10
     42 
     43 #PubkeyAuthentication yes

     …

     63 #PasswordAuthentication yes
     64 #PermitEmptyPasswords no
     65 PasswordAuthentication yes   → (without-password)

 

PermitRootLogin

 yes : 사용자가 root로 로그인할 수 있다.

 no : 사용자가 root로 로그인할 수 없다.

 without-password 암호기반 인증은 금지하고, 개인 키 기반 인증만 허용(조건적 허용)

PasswordAuthentication

 yes : 암호기반 인증을 사용 허용

 no : 암호기반 인증을 사용 금지 

 without-password 암호기반 인증은 금지하고, 개인 키 기반 인증만 허용(조건적 허용)

 

파일을 변경저장한 후에는 systemctl restart(reload) ssh.service

※ ssh 암호 기반 인증을 끄는 경우 원격 서버에서 사용자의 ~/.ssh/authorized_keys 파일이 공개 키로 채워져 로그인할 수 있도록 확인하는 방법이 있어야한다.

 

$ scp

$ scp SOURCE_FILE USER@HOST:DESTINATION :현재 호스트에서 다른 호스트로 파일 복사

$ scp file1 user@192.168.56.12:/home/user

file1                                 100%   20    17.7KB/s   00:00  

[root@host2 20210428]# scp file3 file4 user@192.168.56.12:/home/user (여러개의 파일 설정)
file3                                 100%   17    14.4KB/s   00:00    
file4                                 100%   47    54.6KB/s   00:00  

 

$ scp USER@HOST:SOURCE_FILE DESTINATION : 다른 호스트의 파일을 현재 호스트로 파일 복사

[root@host2 20210428]# scp user@192.168.56.12:/etc/hosts 
hosts                                 100%  158   163.4KB/s   00:00 

[root@host2 20210428]# scp user@192.168.56.12:/etc/resolv.conf /root/20210428/

resolv.conf                           100%   68    72.0KB/s   00:00 

 

[user@host1 work]$ scp -r testdir user@192.168.56.12:/home/user 폴더 복사 (-r 옵션)
filea                                 100%   68    87.4KB/s   00:00    
fileb                                 100% 1036     1.8MB/s   00:00  

 

 

====================================================

 

NTP (Network Time Protocol)

 네트워크 기반의 시간 동기화 프로토콜

 Stratum 단위로 계층적인 구조를 가짐

 

Stratum 0 ~ 15

 Stratum 0 에 가까울 수록 정밀도가 높은 시간을 획득함.

 

Stratum 0 : 가장 정밀도가 높은 계층으로 Primary Reference Clock이라고 함.

                원자시계, GPS가 해당됨.

 

Stratum 1 : Stratum 0로부터 시간정보를 수신하고 동기화 하는 계층
                일반 Host 들이 사용 가능한 최상위 계층임.
                Stratum 2 이외에는 시간정보를 제공하지 않도록 구성함.


Stratum 2 : Stratum 1으로부터 시간정보를 수신하고 동기화하는 계층
                일반적인 시간 동기화 요청에 대해 응답하는 NTP 서버

Stratum n : 자신보다 상위 계층으로부터 시간을 동기화함.

 



 

chrony (/etc/chrony.conf)
  - CentOS7에서 네트워크 시간 동기화를 관리하기 위해 사용하는 기본 패키지
  - chrony는 서버(chronyd)와 클라이언트(chronyc)로 구성되어있음.

 

#chrony tracking

  - Reference ID  : 동기화된 서버 정보
  - Stratum :  현재 시스템의 Stratum 계층 정보
  - Ref time(UTC) :  기준이 되는 시간 정보
  - System time :  NTP Time Server와의 시간 오차
  - Update interval :  동기화 업데이트 간격

 

#chronyc sources

#chronyc sources -v

  M : Mode

기호 의미
^ server
= peer
# local

  S : State

기호 의미
* 현재동기화되는 소스
+ 사용가능한 소스
- 사용가능하지만 제외됨
? 연결이 안됨
x 시간이 부정확함
~ 시간 변동폭이 큼

  Poll :  측정 간격
  Reach : 전송에 대한 유효 응답 횟수
  LastRx :  서버로부터 마지막 샘플을 받은 시간
  LastSample :  마지막 측정시 로컬 시간과의 오차 범위

 

 

 

 

 

CMOS Battery (최소한의 전력)로 실시간으로 시간을 생성 유지 해주는 장치 : RTC (real-time clock)

[root@host1 ~]# systemctl start chronyd.service
[root@host1 ~]# chronyc tracking
Reference ID    : D3E9284E (send.mx.cdnetworks.com)
Stratum         : 3
Ref time (UTC)  : Wed Apr 28 06:47:46 2021
System time     : 0.089477323 seconds fast of NTP time
Last offset     : +0.000414803 seconds
RMS offset      : 0.000414803 seconds
Frequency       : 9.867 ppm fast
Residual freq   : +0.001 ppm
Skew            : 84.541 ppm
Root delay      : 0.010526574 seconds
Root dispersion : 0.032916356 seconds
Update interval : 0.7 seconds
Leap status     : Normal

 

 

 

 

 

 

 

 

728x90

'linux' 카테고리의 다른 글

20210430 (금)  (0) 2021.04.30
20210429 (목)  (0) 2021.04.29
20210427 (화)  (0) 2021.04.27
20210426 (월)  (0) 2021.04.26
20210423 (금)  (0) 2021.04.23
Comments