How to Disable snap/snapd services in Ubuntu 20.04.1 LTS (& How to Uninstall/Remove snap)

The Issue
We want to disable snapd service on system startup/prevent snapd services startup automatically on system boot on Ubuntu or remove Snap completely

The Fix
1 Disable snap services
1.1 Bring up the terminal or login via SSH

1.2 E1xecute following commands to disable snap services

sudo systemctl disable snapd.service
sudo systemctl disable snapd.socket
sudo systemctl disable snapd.seeded
sudo systemctl disable snapd.snap-repair.timer

1.3 Restart the system

sudo reboot

1.4 Now the snap service will not start on system startup

2 Removing Snap

To uninstall snap (If necessary), we need to make sure snap is not used at all.

If we want to uninstall/remove snap just follow the below steps

2.1 List all snaps

snap list

2.2 If there is any installed snap pckage e.g. bashtop, remove all of them one by one

sudo snap remove bashtop

2.3 Find the snap core service directory ID

df

From the output, under the “Mounted on” column, find the ones with “/snap/core/xxxx”

2.4 Unmount the snap core service

sudo umount /snap/core/xxxx

2.5 Remove all snapd package

sudo apt purge snapd

2.6 Remove all directories (If necessary), be careful with the rm command, we will lose data if done incorrectly

rm -rf ~/snap
sudo rm -rf /snap
sudo rm -rf /var/snap
sudo rm -rf /var/lib/snapd

서버에서 주기적으로 Ping 하고 이메일 알람 전송

다음과 같은 스크립트 추가 후,

crontab 에

* * * * * 사용자 실행

추가

#!/bin/sh
HOSTS=”SERVER ADDRESS”
COUNT=1
EMAIL=”EMAIL ADDRESS”

pingtest(){
  for myhost in “$@”
  do
    echo “host ping : $HOSTS”
    ping -c “$COUNT” “$HOSTS” -w 5 && return 1
  done
  return 0
}
pingtest $HOSTS
if [ $? -eq 1 ]
then
  #echo “Everyting is fine” | mail -s “Server is OK ” $EMAIL
  echo “Everyting is fine”
else
  echo “Server ($HOSTS) Pint Test Failed at $(date)” | mail -s “Server is down from KPOPMART DB” $EMAIL
  echo “Host ($HOSTS) is down (PING failed) at $(date)”
fi

텍스트큐브에서 워드프레스로 이전했습니다.

지난 12년을 사용하던 텍스트 큐브에서 워드프레스로 이전했습니다.

미루고 미루다가.. 결국은 이전했습니다.

이전하면서 각 글의 링크가 틀어졌지만 선택의 여지가 없었네요.

찾고자 하시는 글이 있으시면 오른쪽 상단 검색에서 찾아주시기 바랍니다.

감사합니다.

how to upgrade openssl for apache 2.2.29 – still using old 0.9.8 version

I am running a 10.04LTE server where I do want to upgrade openssl for apache.

Therefore I downloaded openssl 1.0.2c and apache 2.2.29 and compiled both. The server is starting, but is using the old ssl version:

curl --head http://localhost
HTTP/1.1 200 OK
Date: Mon, 22 Jun 2015 06:00:06 GMT
Server: Apache/2.2.29 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8k
Last-Modified: Sun, 18 Mar 2012 19:56:07 GMT

However, Openssl is installed in new version:

/usr/local/ssl/bin/openssl version
OpenSSL 1.0.2c 12 Jun 2015

While the original version stayes in place:

openssl version
OpenSSL 0.9.8k 25 Mar 2009

I compiled apache with:

./configure --with-included-apr --prefix=/usr/local/apache2 --enable-so     
--enable-rewrite --with-ssl=/usr/local/ssl --enable-ssl=shared
--enable-deflate --enable-expires --enable-headers 

Apache did not start before I included:

LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so

According to the mod ssl website this is only available for apache 1.x

Not sure what is going wrong here. Thank you for any help!

1 Answer
1

The problem is that your Apache installation is unable to link the shared libraries of your new OpenSSL installation. Run the command ldd /usr/local/apache/modules/mod_ssl.so (with the apporpriate path to your mod_ssl.so). You’ll see that mod_ssl.so is not linking to the libraries in /usr/local/ssl/lib

You have a couple options to fix the problem:

Option #1 – Link in the libraries:

Open /etc/ld.so.conf.d/local.conf for editing and add the following line: /usr/local/openssl/lib

Re-compile Apache (remember to make clean) and it should work.

If that doesn’t work. You could also try specifying LDFLAGS directly with your configure command:

LDFLAGS=-L/usr/local/ssl/lib \ ./configure --with-included-apr --prefix=/usr/local/apache2 --enable-so     
--enable-rewrite --with-ssl=/usr/local/ssl --enable-ssl=shared
--enable-deflate --enable-expires --enable-headers

Option #2 – Upgrade the system OpenSSL:

Re-install OpenSSL with the config line ./config --prefix=/usr --openssldir=/usr/local/openssl shared

When the prefix is not specified in your config line, the OpenSSL installer will default to /usr/local/ssl.

Quick install instructions:

cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz
tar -zxf openssl-1.0.2*
cd openssl-1.0.2*
./config --prefix=/usr --openssldir=/usr/local/openssl shared
make
make test
make install

아파치 SSL 로 구동시 키 비밀번호 없애기 – Some of your private key files are encrypted for security reasons.

SSL 인증서 생성시 인증키 값을 넣을경우
아파치 구동시 키 비밀번호를 입력하지 않으면 구동되지 않는다.



Apache/2.2.13 mod_ssl/2.2.13 (Pass Phrase Dialog)
Some of your private key files are encrypted for security reasons.
In order to read them you have to provide the pass phrases.


Server test.com:443: (RSA)
Enter pass phrase:



서버를 관리하는 입장에서는 비밀번호를 입력하지 않고 자동으로 웹서버를
구동하여야할때가 있다.
 
인증서 생성시 이미 넣어버린 키는 아래와 같이 하면 간단하게 없앨 수 있다.
단, 당연한 이야기지만 기존 비밀번호는 알고있어야한다.-.-;


cp server.key server.key.org
openssl rsa -in server.key.org -out server.key

다시 아파치를 restart 해본다.

Apache SSL 인증서 설치 / 적용 가이드

원문 : https://www.securesign.kr/guides/Apache-SSL-Certificate-Install

사전 구성 환경

  • OpenSSL 라이브러리 http://www.openssl.org/ : openssl 1.0.1 이상 권장
  • Apache w/mod_ssl http://www.modssl.org/ : http.conf 에서 mod_ssl 모듈 활성화 (LoadModule ssl_module modules/mod_ssl.so)
  • TLS / SHA-2(sha256) 암호화 지원 모듈 구성/활성 확인 필수
  • MD5, RC4 등 국제 보안 기구에서 해제를 권장하는 취약한 암호화 모듈 비활성화
  • SSL 2.0, 3.0 및 TLS 1.0 1.1 프로토콜 접속 허용 해제. 최신 TLS 1.2 1.3 설정 권장

진행 과정

  1. 개인키(Private Key) 생성
  2. CSR(Certificate Signing Request) 생성
  3. 인증서 발급 신청 제출
  4. 인증서 발급 완료 (발급내역서/파일설명서 PDF 참조)
  5. 인증서 설치 적용 – 신규,갱신,재발급,도메인추가
  6. 서버 정상 적용 완료 테스트
  7. 웹페이지에 https:// 링크 적용

개인키(Private Key) 생성


– SSL 인증서 발급 신청서 작성시, CSR 입력 단계에서 온라인 “CSR 자동생성” 이용을 권장합니다. (현재 과정 필요 없음)
– CSR 자동생성 발급 완료시, “개인키, 서버인증서, 체인인증서, 루트인증서” PEM 파일이 모두 포함되어 있습니다.
– 추가 포함된 “pfx / jks” 패키지에는, “개인키+서버인증서+체인인증서+루트인증서” 가 모두 통합되어 있습니다.
openssl genrsa -des3 -out private.key 2048
  • -des3 : 개인키 암호화 수준 DES3 (Windows Apache 환경은 해당 옵션 제외)
  • -out private.key : 개인키를 저장할 파일명 지정. 개인키 파일은 분실하지 않도록 잘 보관해야 합니다.
  • 2048 : bit

Result


Loading ‘screen’ into random state – done
Generating RSA private key, 2048 bit long modulus
……………………..+++
……………………………………………..
…………………+++
e is 65537 (0x10001)
Enter pass phrase for pri.kery: (개인키 파일 암호 입력)
Verifying – Enter pass phrase for pri.kery: (개인키 파일 암호 입력)

CSR(Certificate Signing Request) 생성 예


– SSL 인증서 발급 신청서 작성시, CSR 입력 단계에서 온라인 “CSR 자동생성” 이용을 권장합니다. (현재 과정 필요 없음)
– CSR 자동생성 발급 완료시, “개인키, 서버인증서, 체인인증서, 루트인증서” PEM 파일이 모두 포함되어 있습니다.
– 추가 포함된 “pfx / jks” 패키지에는, “개인키+서버인증서+체인인증서+루트인증서” 가 모두 통합되어 있습니다.
openssl req -new -key private.key -out out.csr -config “../share/openssl.cnf”


또는
openssl req -new -key private.key -out out.csr -subj “/C=KR/ST=Seoul/L=Gang-nam/O=SecureSign.KR/OU=Dev Team/CN=example.com”
  • -key private.key : 앞서 생성한 개인키 파일 지정
  • -outout.csr : 생성될 CSR 파일명 지정
  • -config “../share/openssl.cnf” : cnf 위치를 확인하지 못하는 경우 cnf 파일 경로 지정
  • -subj : CSR 생성시 입력이 필요한 정보 지정
    • C : ISO 국가 코드 KR, US, CN, JP (대문자)
    • ST : 시,도
    • L : 구,군
    • O : 기관명, 회사명
    • OU : 조직명
    • CN : 도메인명, 일반이름. IP 주소는 CN 으로 사용할수 없습니다.
    • 위 항목은 모두 영문입력을 해야 합니다. 특수문자를 사용하면 안됩니다.

  • (예제에 사용된 옵션 값 등은 예제용이므로, 실제 해당 도메인 정보로 지정하시기 바랍니다)

Single

CN : sub.example.com 처럼 FQDN 도메인 형식 이어야 합니다.

Wildcard

CN : *.example.com 과 같은 패턴 이어야 합니다.

MultiDomain

CN : example.com 대표성을 가진 FQDN 도메인 1개만 입력 합니다.
SAN : 인증서에 포함될 나머지 FQDN 도메인은, 신청서 작성중 DCV 설정 단계에서 추가 입력합니다.

Multi-Wildcard

CN : example.com 대표 루트 도메인 1개을 CN으로 입력 합니다.
SAN : *.example.com 형식의 와일드카드 도메인은, 신청서 작성중 DCV 설정 단계에서 추가 입력합니다.

Result


Enter pass phrase for pri.kery: (개인키 패스워드 입력)
Loading ‘screen’ into random state – done
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:KR (국가코드 C)
State or Province Name (full name) [Some-State]:Seoul (시,도 ST)
Locality Name (eg, city) []:Gang-nam (구,군 L)
Organization Name (eg, company) [Internet Widgits Pty Ltd]:SecureSign.KR (기관명 O)
Organizational Unit Name (eg, section) []:Dev Team (조직명 OU)
Common Name (eg, YOUR name) []:example.com (도메인명 CN)
Email Address []:webmaster@example.com (이메일)

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []: enter (설정 X)
An optional company name []: enter (설정 X)

생성된 CSR 예제


– SSL 인증서 발급 신청서 작성시, CSR 입력 단계에서 온라인 “CSR 자동생성” 이용을 권장합니다. (현재 과정 필요 없음)
– CSR 자동생성 발급 완료시, “개인키, 서버인증서, 체인인증서, 루트인증서” PEM 파일이 모두 포함되어 있습니다.
– 추가 포함된 “pfx / jks” 패키지에는, “개인키+서버인증서+체인인증서+루트인증서” 가 모두 통합되어 있습니다.
-----BEGIN CERTIFICATE REQUEST-----
MIIC5TCCAc0CAQAwgZ8xCzAJBgNVBAYTAktSMQ4wDAYDVQQIEwVTZW91bDERMA8G
A1UEBxMIR2FuZy1uYW0xGDAWBgNVBAoTD1NlY3VyZUxheWVyIEluYzERMA8GA1UE
-- 중략 --
wxd+87gwsvAC2dyK8I4N1ttXDRJcDPCDe1BGqWvYYAZN7FbvnbHCM7y/SN++pxbS
jbnkoe8uStQvfCo6DW5MZHUli5+lRU/UpA==
-----END CERTIFICATE REQUEST-----

앞서 생성한 CSR 파일은 Base64 포맷의 PEM Text 이며, 텍스트 편집기를 이용하여 파일을 오픈합니다. -----BEGIN ~ REQUEST----- 까지 포함하여 내용 전체를 복사하여 신청서에 입력합니다. (—– 를 누락하거나, 새로운 빈출이 추가되지 않도록 주의하세요)

인증서 발급 완료 및 참고 사항

– 발급 완료 후에는, 메일첨부 또는 주문상세의 압축파일(zip)에 인증서 파일이 포함되어 있습니다.
– 서버 적용에 필요한 파일들에 대해서, 발급 내역서 PDF 및 루트/체인 설명 PDF를 통해서 미리 숙지해야 합니다.
– 이후 과정 부터는, 서버에 SSL 인증서 설치/적용/확인 절차 입니다. (인터넷에 공개된 설정법과 차이 없음)

– 서버이름표시(SNI) 지원되는 서버의 경우, SSL 인증서 마다 각 포트 구분없이 모두 443 포트 적용가능합니다.
– SNI 설정으로 하는 경우, 클라이언트에서 SNI 미지원 하는 경우 접속 호환성 문제가 있으므로 미리 검토해야 합니다.

VirtualHost 적용 예제 (서버 인증서 발급 받은 후)

<VirtualHost *:443>

ServerName “아래 지정한 서버 인증서에 포함된 DNS Name 중에 있어야 함 ”
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3 또는 TLSv1 TLSv1.1 TLSv1.2 (서버 환경에 따라서 선택적 적용)
SSLCertificateKeyFile /인증서파일경로/개인키 ex. domain_xxxxx.key.pem
SSLCertificateFile /인증서파일경로/서버인증서 ex. domain_xxxxx.crt.pem
SSLCertificateChainFile /인증서파일경로/체인인증서ex. chain-bundle.pem
SSLCACertificateFile /인증서파일경로/루트인증서 ex. AAACertificateServicesRoot.crt.pem

</VirtualHost>

* 루트/체인 인증서는 상품별로 차이가 있으므로, 발급 완료시 첨부된 파일 내역에서 확인 가능합니다.
* chain-bundle.pem 은 체인인증서가 여러개인 경우 1개 파일로 통합한 PEM Text 파일입니다.
* CSR 자동 생성 이용시, 개인키에는 패스워드가 지정되지 않습니다. (별도 지정 필요시 변환 매뉴얼 참조)
* 예제에 포함되어 있지 않은 나머지 Property 는 공식 매뉴얼 또는 현재 서버 설정값을 사용하시기 바랍니다. (/conf/extra/httpd-ssl.conf 참조)

VirtualHost 적용 예제 – Apache 2.4.8 + (서버 인증서 발급 받은 후)

<VirtualHost *:443>

ServerName “아래 지정한 서버 인증서에 포함된 DNS Name 중에 있어야 함 ”
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3 또는 TLSv1 TLSv1.1 TLSv1.2 (서버 환경에 따라서 선택적 적용)
SSLCertificateKeyFile /인증서파일경로/개인키 ex. domain_xxxxx.key.pem
SSLCertificateFile /인증서파일경로/서버+체인 PEM 통합된 파일 ex. domain_unified.pem
SSLCACertificateFile /인증서파일경로/루트인증서 ex. AAACertificateServicesRoot.crt.pem

</VirtualHost>

* 루트/체인 인증서는 상품별로 차이가 있으므로, 발급 완료시 첨부된 파일 내역에서 확인 가능합니다.
* 통합 pem 파일 생성 : cat domain_xxxxx.crt.pem chain-bundle.pem > unified.domain.pem (cat, type 명령어 사용)
* 통합된 domain_unified.pem 파일을 Text 편집기로 열어서, PEM 내용간 구분되어 있는지 꼭 확인해야 합니다.
* CSR 자동 생성 이용시, 개인키에는 패스워드가 지정되지 않습니다. (별도 지정 필요시 변환 매뉴얼 참조)
* 예제에 포함되어 있지 않은 나머지 Property 는 공식 매뉴얼 또는 현재 서버 설정값을 사용하시기 바랍니다. (/conf/extra/httpd-ssl.conf 참조)

설치 적용 확인 및 변환

* 서버에 SSL 설정 적용 후, 웹서버를 재시작하여 시작시 오류 또는 경고가 있는지 콘솔/데몬 로그를 필히 확인해야 합니다. (필수 확인 사항)
* SSL 발급 도메인 웹페이지에 https:// 링크 적용을 별도 진행해야 최종적으로 SSL 암호화가 적용됩니다. (개발자,웹디자이너)
* PC 및 스마트폰의 “Chrome / Firefox / IE / Edge” 각 웹브라우져에서 “루트,체인,SSL,TLS” 경고가 발생 하는지 확인해야 합니다.

SSL 설치/적용 트러블슈팅
SSL 설치 적용 확인 하기
체인인증서 적용 확인 방법
인증서 포맷 변환 방법
TrustLogo 적용 방법

Plex Media Server – Cache Folder 이동

The Plex Media Server cache resides in %USERPROFILE%\Local Settings\Application Data\Plex Media Server
NOTE: For XP – C:\Documents and Settings\USERNAME\Local Settings\Application Data\Plex Media Server

If your drive is running out of space you can move it to another location by:

  • Close Plex Media Server from the System Tray
  • Use Robocopy to copy the cache folder to a new location e.g. D:\Plex Media Server

    Execute – Robocopy.exe “C:\Documents and Settings\USERNAME\Local Settings\Application Data\Plex Media Server” “D:\Plex Media Server” /E

    NOTE1: Windows Explorer is unable to copy some files (com.plexapp.agents.thetvdb_4ccc065777fa44d06bbc4542ac5544325fc53bbf)
    NOTE2: If using XP – Robocopy is part of the Windows Server 2003 Resource Kit Tools available here – http://www.microsoft.com/en-au/download/confirmation.aspx?id=17657 18

  • Rename the “C:\Documents and Settings\USERNAME\Local Settings\Application Data\Plex Media Server” folder to “Plex Media Server_OLD”
  • Open Regedit.exe, browse to HKEY_CURRENT_USER -> Software -> Plex, Inc. -> Plex Media Server and create a String Value called “LocalAppDataPath”. Set its value to D:<br>
    NOTE3: On Win 7 – You could instead use the mklink comand to create a link from C:\Users\USERNAME\Local Settings\Application Data\Plex Media Server to D:\Plex Media Server
  • Restart Plex and ensure it’s working
  • Delete the renamed Plex Media Server_OLD folder

    Open cmd.exe and Execute – Rmdir /S “C:\Documents and Settings\USERNAME\Local Settings\Application Data\Plex Media Server_OLD”

    NOTE4: Windows Explorer is unable to delete some files (Refer to NOTE1)

리눅스 파일 검색/찾기, 파일 내부 문자열 찾기/검색

# 리눅스 파일명으로 검색하는법.

사용법

find [찾을위치] -name [파일명]

예) 최상위 폴더부터 하위로 ‘apache’로 시작하는 파일 찾기.

find / -name ‘apache*’

예) usr 폴더부터 하위로 ‘apa’로 시작하는 파일 찾기.

find /usr/ -name ‘apa*’

 

# 리눅스 파일 내부 문자열 검색하는법.

grep 을 이럴때 유용하게 쓸 수 있습니다.

사용법

grep -r [찾을 문자열] [대상파일들]

예) 현재 폴더에 있는 test.log 파일내부에 ‘apache’ 라는 문자열 찾기.

grep -r ‘apache’ ./test.log

예) ‘var’ 폴더부터 하위 모든 파일내부에서 ‘apache’ 라는 문자열 찾기.

grep -r ‘apache’ /var/* [–include ‘*.conf’] (include 옵션으로 특정 확장자에서만 검색도 가능하다)

 

# 파일 내부 문자열 검색 다른 방법 (Feat. 강조색)

find . -type f -print | xargs grep -i “phpMyAdmin” /dev/null

현재위치부터 하위폴더의 모든 파일중에서 ‘phpMyAdmin’ 이라는 문자열을 검색한다.

find . -name ‘*.conf’ | xargs grep -r –color=auto -n 2>dev/null ‘phpMyAdmin’

현재 부터 하위 모두를 검색하되,

conf 라는 확장자를 가진 파일중에서 ‘phpMyAdmin’ 이라는 문자열을 검색한다.

그리고 일치 문자열은 강조색으로 표시!