wget 으로 웹소스 출력하기

리눅스/OS 일반|2023. 1. 4. 07:41
반응형

예)

# wget -qO- https://sysdocu.tistory.com

 

 

반응형

댓글()

Ubuntu 22.04 Desktop 설치 후 한글 사용하기 외 PC 로 활용할 기본 프로그램 목록

리눅스/OS 일반|2022. 11. 15. 10:10
반응형

한글 사용하기

1. settings - Region & Language - Install / Remove Languages -> Korean 박스 체크

reboot

2. terminal - ibus-setup

3. input method - add - korean 검색 - korean - Hangul add

4. settings - input sources - + 클릭 - Korean - Korean (Hangul) add

5. 바탕화면 우측 상단에 add된 Korean(hangul) 선택

[출처] https://jay-daily.tistory.com/201

 

 

우분투 소프트웨어에서 설치

remmina, filezilla, telegram, gedit, 스크린샷

 

 

동영상 플레이어

# apt -y install smplayer

기본 프로그램 등록 : 셋팅 > 기본 응용 프로그램 > 영상 (SMPlayer) 선택

 

 

네이버 웨일 브라우저

 

 

반응형

댓글()

[에러] Too many open files 조치하는 방법 (ulimit 명령어)

리눅스/OS 일반|2022. 9. 14. 16:59
반응형

OS 내에서 작업중 어디에선가 아래와 같은 메세지가 출력될 경우 ulimit 를 활용해보도록 합니다.

 

에러 : 'Too many open files'

조치 : ulimit 명령어 사용

 

우선 많은 파일을 열기 위해서는 ulimit 에서 오픈가능한 파일의 최대 수를 조정해주어야 합니다.

OS 기본값은 1024 입니다.

동시에 여는 파일이 많을 수록 더 많은 메모리 양을 필요로 한다는 것을 참고 하고, 필요한 값으로 조정을 합니다.

예제에서는 50000으로 조정하는 내용을 담았습니다.

 

1. 현재 설정값 확인

 

# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256092
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 256092
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

 

2. 설정값 변경 (일시적)

 

# ulimit -n 50000

 

(변경 내용 확인)

# ulimit -a |grep 'open files'
open files                      (-n) 50000

 

변경이 되었습니다. 하지만 재로그인 또는 리부팅의 작업을 거치면 다시 원래의 1024 값으로 돌아가므로

변경값이 기본으로 셋팅 되도록 해봅니다.

 

3. 설정값 변경 (영구적)

 

설정파일의 맨 아래에 아래 4줄 내용을 추가 하면 재로그인 또는 리부팅 후에도 변경된 값을 유지하게 됩니다.

설정 내용중 * 표시는 root 를 제외한 모든 계정을 의미합니다.

 

# vi /etc/security/limits.conf

 

root     soft nofile 50000

root     hard nofile 50000

*        soft nofile 50000

*        hard nofile 50000

 

 

반응형

댓글()

GCC 원하는 버전으로 업그레이드 하기 (CentOS 7, GCC 10.3.0)

리눅스/OS 일반|2022. 6. 17. 08:12
반응형

1. 현재 버전 확인
# gcc --version


2. 업그레이드
GCC 는 아래 공식 사이트에서 원하는 버전을 다운로드 받을 수 있습니다.

https://gcc.gnu.org/releases.html

# wget https://ftp.kaist.ac.kr/gnu/gcc/gcc-10.3.0/gcc-10.3.0.tar.gz
# tar xvzf gcc-11.3.0.tar.gz
# cd gcc-11.3.0
# ./configure --disable-multilib --enable-languages=c,c++
# make
# make install


3. 변경된 버전 확인
# gcc --version

 

반응형

댓글()

Zabbix API 예제

리눅스/OS 일반|2022. 4. 22. 15:59
반응형

[ PHP 코드 ]

아래 샘플 코드를 이용해 토큰을 출력해 봅니다.

<?php
$curl = curl_init() ;

curl_setopt ( $curl , CURLOPT_URL , 'http://sysdocu.tistory.com/api_jsonrpc.php' ) ;
curl_setopt ( $curl , CURLOPT_TIMEOUT , 10 ) ;
curl_setopt ( $curl , CURLOPT_POST , 1 ) ;
curl_setopt ( $curl , CURLOPT_RETURNTRANSFER , 1 ) ;
curl_setopt ( $curl , CURLOPT_SSL_VERIFYPEER , FALSE ) ;
curl_setopt ( $curl , CURLOPT_HTTPHEADER , array ( 'Content-Type: application/json'  ) ) ;
curl_setopt ( $curl , CURLOPT_POSTFIELDS , '{"jsonrpc":"2.0" , "method":"user.login" , "params":{"user":"Admin", "password":"12345678"} , "auth":null, "id":1}' ) ;

$result = curl_exec ( $curl ) ;
$err = curl_error ( $curl ) ;

curl_close ( $curl ) ;

if ( $err )
  echo 'Error :' . $err ;
else
  echo $result;


$data = json_decode($result, true);
$token = $data['result'];
echo $token
?>


[ BASH 코드 ]

#!/bin/bash

TOKEN=`curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "method": "user.login", "params": { "user": "Admin", "password": "12345678" }, "id":1 }' 'http://sysdocu.tistory.com/api_jsonrpc.php' |sed -e "s/.*\"result\":\"//;s/\".*//"`

echo -e "TOKEN : $TOKEN\n"

 

[ API 종류 ]

더 자세한 API 종류 및 설명은 zabbix 공식 사이트를 참고해주세요.

아래는 curl 명령을 기준으로 작성하였습니다.

PHP 코드는 아래 코드와 맨 위 PHP 예제 파일을 참고해서 작성하면 됩니다.


1) 토큰 생성
Admin 계정으로 토큰을 생성해야 생성된 토큰으로 계정 추가, 삭제가 가능합니다.

(명령)
curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{
    "jsonrpc": "2.0", 
"method": "user.login", 
"params": { 
    "user": "Admin", 
"password": "12345678" 
}, 
"id":1
}' 'http://sysdocu.tistory.com/api_jsonrpc.php'

 


(결과)
{
    "jsonrpc":"2.0",
"result":"c436f84f928956be8db12704db759376",
"id":1
}


2) 계정 생성
'${TOKEN}' 부분에 위에서 생성한 토큰이 들어갑니다.
usrgrpid 값 16은 임의로 만든 값입니다.

(명령)
curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{
    "jsonrpc": "2.0",
    "method": "user.create",
    "params": {
        "alias": "CDH",
        "passwd": "1234",
        "roleid": "1",
        "usrgrps": [
            {
                "usrgrpid": "16"
            }
        ],
        "medias": [
            {
                "mediatypeid": "16",
                "sendto": [
                    "123456789"
                ],
                "active": 0,
                "severity": 63,
                "period": "1-7,00:00-24:00"
            }
        ]
    },
    "auth": "'${TOKEN}'",
    "id": 2
}' 'http://sysdocu.tistory.com/api_jsonrpc.php'

(결과)
{
  "jsonrpc": "2.0",
  "result": {
    "userids": [
      "20"
    ]
  },
  "id": 2
}


3) 계정 삭제
생성시 부여되었던 userids 값을 사용합니다.

(명령)
curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{
    "jsonrpc": "2.0",
    "method": "user.delete",
    "params": [
        "20"
    ],
        "auth": "'${TOKEN}'",
    "id": 1
}' 'http://sysdocu.tistory.com/api_jsonrpc.php'

(결과)
{
  "jsonrpc": "2.0",
  "result": {
    "userids": [
      "20"
    ]
  },
  "id": 1
}


4) 유저 리스트
(명령)
curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{
    "jsonrpc": "2.0",
    "method": "user.get",
    "params": {
        "output": "extend"
    },
    "auth": "'${TOKEN}'",
    "id": 1
}' 'http://sysdocu.tistory.com/api_jsonrpc.php'


5) 그룹 리스트
(명령)
curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{
    "jsonrpc": "2.0",
    "method": "usergroup.get",
    "params": {
        "output": "extend",
        "status": 0
    },
    "auth": "'${TOKEN}'",
    "id": 1
}' 'http://sysdocu.tistory.com/api_jsonrpc.php'

 

아래는 쉘스크립트 코드 입니다. curl 형식은 동일합니다.


# 호스트 그룹 추가
HOSTGROUP_ADD=`curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{
    "jsonrpc": "2.0",
    "method": "hostgroup.create",
    "params": {
        "name": "sysdocu"
    },
    "auth": "'${TOKEN}'",
    "id": 1
}' 'http://sysdocu.tistory.com/api_jsonrpc.php' | jq '.'`
echo -e "호스트 그룹 생성 결과\n${HOSTGROUP_ADD}"


# 호스트 그룹 리스트 출력
HOSTGROUP_GET=`curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{
    "jsonrpc": "2.0",
    "method": "hostgroup.get",
    "params": {
        "output": "extend"
    },
    "auth": "'${TOKEN}'",
    "id": 1
}' 'http://sysdocu.tistory.com/api_jsonrpc.php' | jq '.'`
echo -e "호스트 그룹 리스트 출력 결과\n${HOSTGROUP_GET}"


# 유저 그룹 추가
GROUP_ADD=`curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{
    "jsonrpc": "2.0",
    "method": "usergroup.create",
    "params": {
        "name": "sysdocu",
        "rights": {
            "id": "37",       // 호스트 그룹 id
            "permission": 3   // 권한 (RW)
        }
    },
    "auth": "'${TOKEN}'",
    "id": 1
}' 'http://sysdocu.tistory.com/api_jsonrpc.php' | jq '.'`
echo -e "그룹 생성 결과\n${GROUP_ADD}"


# 유저 그룹 삭제
GROUP_DEL=`curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{
    "jsonrpc": "2.0",
    "method": "usergroup.delete",
    "params": [ "18" ],
    "auth": "'${TOKEN}'",
    "id": 1
}' 'http://sysdocu.tistory.com/api_jsonrpc.php' | jq '.'`
echo -e "그룹 삭제 결과\n${GROUP_DEL}"


# 호스트 그룹 삭제
HOSTGROUP_DEL=`curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{
    "jsonrpc": "2.0",
    "method": "hostgroup.delete",
    "params": [ "32" ],
    "auth": "'${TOKEN}'",
    "id": 1
}' 'http://sysdocu.tistory.com/api_jsonrpc.php' | jq '.'`
echo -e "호스트 그룹 삭제 결과\n${HOSTGROUP_DEL}"


* 참고

roleid
1 : User role
2 : Admin role
3 : Super role
4 : Guest role

mediatypeid
1 : email
2 : x
3 : sms
4 : email
5 : Mattermost
6 : Opsgenie  
7 : PagerDuty
8 : Pushover
9 : Slack
10 : discord
11 : SIGNL4
12 : Jira
13 : Jira with CustomFields  
14 : MS Teams  
15 : Redmine
16 : Telegram

반응형

댓글()

[PHP] 여러개의 파일 읽기 (fopen multiple files in php)

리눅스/OS 일반|2022. 4. 19. 10:56
반응형

1. 특정 파일을 지정해서 읽을 경우 (array 배열에 파일명을 넣어줍니다)

<?PHP
$filenames = array("../logs/detect.log.1", "../logs/detect.log");
foreach ($filenames as $file) {
    $file_handle = fopen($file, "r");
    while (!feof($file_handle)) {
        $line = fgets($file_handle);
        echo $line;
    }
    fclose($file_handle);
}
?>

[출처] https://stackoverflow.com/questions/47992424/using-php-how-to-read-multiple-text-files-and-display-the-file-name

 

존재하는 파일만 읽고 싶은 경우, 파일이 있을때만 array 에 넣는 방법으로 해도 됩니다.

<?php
$filenames = array();

if (file_exists("../logs/detect.log.1")) {
    array_push($filenames, "../logs/detect.log.1");
}

if (file_exists("../logs/detect.log")) {
    array_push($filenames, "../logs/detect.log");
}

if (count($filenames) != "0") {  // 존재하는 파일이 한개라도 있을경우
    foreach ($filenames as $file) {
        $file_handle = fopen($file, "r");
        while (!feof($file_handle)) {
            $line = fgets($file_handle);
            echo $line;
        }
        fclose($file_handle);
    }
}
?>

 

2. 다수의 파일을 읽을 경우 ( * 과 같은 와일드 카드 문자를 이용합니다.)

<?php
foreach (glob("../logs/detect.log*") as $file) {
    $file_handle = fopen($file, "r");
    while (!feof($file_handle)) {
        $line = fgets($file_handle);
        echo $line;
    }
    fclose($file_handle);
}
?>

[출처] https://stackoverflow.com/questions/18558445/read-multiple-files-with-php-from-directory

 

반응형

댓글()

오류: repo 'appstream'의 메타 데이터를 다운로드하지 못했습니다: Cannot prepare internal mirrorlist: No URLs in mirrorlist

리눅스/OS 일반|2022. 4. 12. 07:51
반응형

CentOS 8 에서 yum 실행시 출력된 에러 메세지 이며 해결은 다음과 같이 하였습니다.

# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*

# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*

 

그리고 충돌하는 패키지 변경을 위해 아래와 같은 옵션을 주며 update 를 하였습니다.

# yum update --allowerasing

 

이제 필요한 패키지 설치가 가능합니다.

 

[출처] https://stackoverflow.com/questions/70926799/centos-through-a-vm-no-urls-in-mirrorlist

반응형

댓글()

리눅스 PC 보안 설정 (Ubuntu 22.04 기준)

리눅스/OS 일반|2022. 4. 4. 10:50
반응형

패스워드 복잡성 설정

# apt-get -y install libpam-pwquality

/etc/pam.d/common-password    25 번째 줄 아래 내용 추가 및 수정
        password    requisite                    pam_pwquality.so retry=3 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1
        password    [success=1 default=ignore]   pam_unix.so obscure use_authtok try_first_pass yescrypt sha512 minlen=6 maxlen=9

계정 잠금 임계값 설정
/etc/pam.d/common-auth    23번째 줄 아래 내용 추가
        auth    required                        pam_permit.so onerr=tail even_deny_root deny=10 unlock_time=300


패스워드 최대 사용기간 설정
/etc/login.defs
        PASS_MAX_DAYS   90
        PASS_MIN_DAYS   0
        PASS_WARN_AGE   7

        PASS_MIN_LEN 8

 

현재 사용중인 계정은 위와 같은 룰이 적용되지 않기 때문에 아래와 같이 개별적으로 설정해줍니다.

(패스워드 최대 사용일 : 90일)

# chage -M 90 root

# chage -M 90 sysdocu

(설정 확인)

# chage -l 90 root

# chage -l 90 sysdocu

 

SUID, SGID, Sticky bit 설정 파일 점검 ( 파일 /sbin/unix_chkpwd은 제외 )
chmod 0755 /sbin/dump 
chmod 0755 /usr/bin/lpq-lpd 
chmod 0755 /usr/bin/newgrp 
chmod 0755 /sbin/restore 
chmod 0755 /usr/bin/at 
chmod 0755 /usr/sbin/traceroute 
chmod 0755 /usr/bin/lpq 
chmod 0755 /usr/bin/lprm-lpd
chmod 0755 /usr/bin/lpr 
chmod 0755 /usr/sbin/lpc 
chmod 0755 /usr/bin/lprm 
chmod 0755 /usr/bin/lpr-lpd 
chmod 0755 /usr/sbin/lpc-lpd 


world writable 파일 점검

파일이 있는지 확인

ll /usr/lib/tmpfiles.d/tmp.conf

cat << EOF >> /etc/ssh/ssh_config
PermitRootLogin no
EOF

cat << EOF > /etc/hosts.deny
ALL : ALL
EOF

chmod 0400 /etc/shadow
chmod 0640 /etc/hosts.deny
chmod 0640 /etc/hosts.allow

ssh 서비스 확인
netstat -nltp |grep ssh
systemctl stop sshd
systemctl disable sshd

반응형

댓글()

CentOS 7 에서 OpenSSH 취약점 (취약한 알고리즘) 조치 방법

리눅스/OS 일반|2022. 3. 31. 12:21
반응형

[ 취약한 알고리즘 ]
Running SSH serviceInsecure CBC ciphers in use: aes128-cbc,aes192-cbc,blowfish-cbc,cast128-cbc,aes256-cbc
Running SSH serviceInsecure 3DES ciphers in use: 3des-cbc
Running SSH serviceInsecure key exchange in use: diffie-hellman-group1-sha1
Running SSH serviceInsecure key exchange algorithms in use: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
Running SSH serviceInsecure MAC algorithms in use: umac-64-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,hmac-sha1

 


[ 현재 허용된 알고리즘 확인 ]
아래와 같은 명령어로 확인이 가능합니다.

 

(명령)

# sshd -T | grep "\(^ciphers\|^macs\|^kexalgorithms\)"

(결과)
ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
macs umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1

kexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1


[ 설정 변경 및 적용 ]
설정 파일을 열어 아래 내용 삽입 (또는 수정) 후 sshd 데몬을 재시작 합니다.
기본 옵션으로 모두 허용되어 있으므로 위 출력 결과에서 사용하지 않을 알고리즘만 제거하고 입력하였습니다.

 

# vi /etc/ssh/sshd_config


ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
macs umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512
kexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1

# service sshd restart

 

 

[ 변경된 알고리즘 재확인 ]

 

(명령)

# sshd -T | grep "\(^ciphers\|^macs\|^kexalgorithms\)"

 

(결과)
ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
macs umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512
kexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1

반응형

댓글()

Ubuntu 18.10 싱글모드 (복구모드) 진입 & 계정 잠김 해제

리눅스/OS 일반|2022. 3. 17. 08:01
반응형

패스워드 임계치 설정을 해 놓고, 정해놓은 수 만큼 패스워드가 불일치 되면 계정이 잠깁니다.

이럴 경우 싱글모드로 진입하여 계정 잠김 해제를 할 수 있습니다.

 

 

1. 싱글모드 진입

시스템 리부팅시 커널 선택 부분에서 아래와 같은 항목 위에서 알파벳 'e' 를 누릅니다.

*Ubuntu    // 아마도 맨 위의 항목

 

에디터 창이 뜨는데 아래서 두번째 라인 (linux 로 시작 하는 라인) 만 수정하면 됩니다.

ro 라는 단어부터 뒤로 모두 지우고 아래 내용으로 대체합니다.

rw init=/bin/bash

그리고 Ctrl + X 키를 눌러 부팅하면 계정 패스워드 없이 root 권한으로 shell 진입하게 됩니다.

 

 

2. 계정 잠김 해제

1) 확인

# pam_tally2 -u 계정명

 

2) 해제

# pam_tally2 -u 계정명 -r

 

 

3. 리부팅

싱글모드에서는 init 6 이나 reboot 명령이 되지 않으므로 강제 리부팅을 시행합니다.

# reboot -f

 

반응형

댓글()

OpenSSL 업그레이드 (소스 설치 / 1.0.1k to 1.1.1o in CentOS 7) 및 APM 적용하기

리눅스/OS 일반|2021. 12. 7. 14:15
반응형

1. OpenSSL 업그레이드

 

# openssl 현재 버전 확인
openssl version 
 
# openssl 설치 위치 확인
which openssl
# /usr/bin/openssl
 
# OpenSSL 지원 프로토콜 확인
openssl ciphers -v |awk {'print $2'} |sort |uniq
  
# 기본 라이브러리 설치
yum -y install gcc gcc-c++ perl pcre-devel zlib-devel wget
 
# 다운로드 및 소스 컴파일

cd /usr/local/src

wget https://www.openssl.org/source/openssl-1.1.1o.tar.gz
tar xvfz openssl-1.1.1o.tar.gz
cd openssl-1.1.1o/ 
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
make && make install
 
# 새로운 파일 생성하여 아래 한줄 추가하고 저장(:wq)한다. (라이브러리 등록)
vi /etc/ld.so.conf.d/openssl-1.1.1o.conf
/usr/local/ssl/lib
 
# 동적 링크 생성
ldconfig -v
 
ln -s /usr/local/ssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/ssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

링크 파일이 있으면 삭제 후 재실행


# 기존 openssl 이름 변경 (기존 패키지 버전명으로 백업)
mv /usr/bin/openssl /usr/bin/openssl1.0.1k
 
# 새로 설치한 버전 심볼릭 링크 생성
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
 
# 업데이트된 버전 확인
openssl version
 
# OpenSSL 지원 프로토콜 확인
openssl ciphers -v | awk '{print $2}' | sort | uniq
openssl1.0.2k ciphers -v | awk '{print $2}' | sort | uniq

출처: https://link2me.tistory.com/2023 [소소한 일상 및 업무TIP 다루기]

 

 

2. APM 적용

 

이미 설치된 APM 은 OpenSSL 업그레이드 버전이 자동으로 적용되지 않으므로

아래와 같은 방법으로 재설치를 하여 SSL 을 적용해야 합니다.

* SSL 설치 경로 : /usr/local/ssl

1) Apache

아래는 2.4.54 에서 확인되었습니다.

# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-rewrite --enable-module=ssl --enable-ssl=shared --with-ssl=/usr/local/ssl --enable-so

# make && make install

# /usr/local/apache/bin/apachectl restart

* 확인 방법 (httpd.conf 에서 mod_ssl.so 모듈이 로드 되어있어야 함)
# curl --head localhost

2) PHP

아래는 8.1.7 에서 확인되었습니다.

export PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig

# ./configure --prefix=/usr/local/php --with-mysqli --with-openssl=/usr/local/ssl --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-zlib --disable-debug --enable-calendar --enable-ftp --enable-sockets --enable-sysvsem --with-curl --enable-mbstring

# make && make install

# /usr/local/apache/bin/apachectl restart

* 확인 방법
# php -r "echo phpinfo();" | grep -i openssl

 

3) MySQL

아래는 8.0.29 에서 확인되었습니다.

 

다른 버전의 라이브러리를 가져올 수 있도록 patchelf 패키지를 우선 설치하고 진행합니다.

# yum -y install patchelf

 

# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DWITH_SSL=/usr/local/ssl -DMYSQL_TCP_PORT=3306 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/mysql-8.0.29/include/boost_1_77_0 -DFORCE_INSOURCE_BUILD=1

 

# make && make install

 

* 확인 방법

# ldd /usr/local/mysql/bin/mysqld |grep ssl

 

4) CURL

아래는 7.88.1 에서 확인되었습니다.

# ./configure --with-ssl=/usr/local/ssl --prefix=/usr/local/curl

# make && make install

# mv /usr/bin/curl /usr/bin/curl.old    // 기존 curl 이 있을 경우

# ln -s /usr/local/curl/bin/curl /usr/bin/curl

 

* 확인 방법

# curl -V

 

반응형

댓글()