Visual Studio: NuGet Package 오프라인 설치 방법

최근 보안이 강화됨에 따라 대부분의 기업내 개발환경에서는 온라인에 접속이 안되는 경우가 많다. 이 런 경우 개발 SDK 를 온라인에서 설치해야 하는데 난감한 경우가 발생한다.

예전 부터 MS에서 제공하는 SDK는 .iso 파일을 받아 설치하면 되었지만 최근 NuGet Pkg 로 배포되는 SDK 는 직접 온라인에서 설치하게 된다.

이러한 경우 필요한 라이브러리를 온라인에서 다운 받아 내부망에서 오프라인으로 설치하는 방법을 소개한다.

  1. 먼저 온라인에서 샘플 프로젝트를 만든다.
  2. 아래와 같이 프로젝트의 ‘참조’ 항목을 선택하고 NuGet Package를 설치한다.
이 이미지는 대체 속성이 비어있습니다. 그 파일 이름은 image.png입니다

필요한 NuGet Package 를 선택하고 설치한다.

  1. Solution file이 저장된 위치에 packages 라는 폴더가 생성된 것이 보인다. 이 폴더에 설치한 NuGet Pkg가 저장된다. 이 폴더를 통채로 압축하여 내부망으로 가져 온다.
  1. 내부망의 작업 PC에 적당한 폴더를 만들고 외부망에서 가져온 NuGet Pkg를 복사한다.
  1. 이제 내부망 PC의 Visual Studio 에서 NuGet Package의 소스 경로를 방금 만들고 복사한 경로를 추가한다.

온라인에서와 같이 프로젝트의 ‘참조’ 를 선택하고 ‘NuGet 패키지 관리’를 선택한 후에 열리는 패키지 관리자에서 우측 상단의 톱니바퀴 모양의 설정 아이콘을 클릭한다.

위에 보이는 것은 초기의 패키지 소스의 내용이다. 여기에 로컬 패키지 소스를 추가한다. 아래 그림의 우상단에서 [+] 아이콘을 누른다.

추가된 ‘Package Source‘ 를 아래와 같이 로컬 소스로 수정한다.

수정 후 확인을 클릭한 후에 패키지 소스를 이제 막 추가한 'Local Package Source' 으로 선택한다.

선택 후 찾아보기 탭을 선택하면 아래와 같이 좀전에 복사한 NuGet Package 가 보인다. 이제 온라인에서와 같이 설치하면 된다.

이렇게 추가하였지만 가끔 이상한 동작을 하는 경우가 있다. 특히 원래 존재하는 NuGet Source를 삭제한 경우에 문제가 되는 경우가 많으므로 초기에 존재하는 NuGet 원본 소스는 삭제하지 않는 것이 좋다.

이제 로컬 NuGet Source로 작업할 때 발생하는 오류에 대한 해결 방법을 소개한다.

  1. 객체 참조가 객체의 인스턴스로 설정되지 않았습니다.” 라는 에러가 발생하는 경우
    이러한 에러는 대부분 NuGet Package Source의 프로토콜 버전에 문제가 있는 경우가 많다. 이 때 아래 파일을 텍스트 편집기로 열고 protocolVersion="3" 이라고 된 부분을 삭제한다. 전체를 삭제하는 것이 아니라 protocolVersion="3" 문자만 삭제한다.

    C:\Users\\AppData\Roaming\NuGet\NuGet.Config

    이 것은 Visual Studio 2015 부터 추가된 것으로 NuGet Source 원본에만 적용된다. Local Source 에서는 삭제한다.
    아래와 같이 표시되면 정상이다.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="Local Package Source" value="C:\_Work\NuGetPackages" />
    <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
  </packageSources>
</configuration>
  1. 컴파일 할 때 패키지가 없다. 라는 메시지가 뜨거나 패키지 업그레이드를 할 때 에러가 발생하는 경우
    이 경우는 Project 에서 이미 등록된 기존 NuGet Package에 대한 기록을 삭제해야 한다. Visual Studio를 종료하고 projectName.vcxproj 파일을 텍스트편집기로 오픈하고 아래와 같이 일부 태그를 삭제한다.
    1. <None Include="packages.config" />‘ 를 찾아서 삭제한다.
    2. <ImportGroup Label="ExtensionTargets">‘ 을 찾아서 해당 섹션을 모두 삭제한다.
    3. <Target Name="EnsureNuGetPackageBuildImports" ...>‘ 을 찾아서 해당 섹션을 모두 삭제한다.

Posted in Window Program | Tagged , , , | Leave a comment

샤오미 물걸레 청소기 밧데리 교체

샤오미 물걸레 청소기를 사용한지 1년이 지나 2년 가까이 되다 보니 전에는 한번 충전으로 온방을 다 청소하고도 남아 돌았는데 이제는 2/3 정도 청소하면 밧데리가 바닥난다.

인터넷에서 교체하려고 밧데리를 찾아 보았지만 마땅한 모델이 없어서 직접 교체용 밧데리를 만들어 보기로 했다.

물걸레 청소기는 D260 모델로서 아래와 같은 모델이다.

밧데리는 18650 3개가 하나로 묶여 있는 형태로 아래와 같은 연결의 밧데리를 구해야 한다. 하지만 국내 쇼핑몰을 한참을 뒤져도 이런 건 없다.

18650 밧데리는 3개를 구입하면 12000원 ~ 20000원 대로 구입이 가능했다. 이왕에 구하기 힘든거라면 한번 낱개로 사서 만들어 보자 생각하고 밧데리 3 개와 홀더를 구입했다.

아래 그림과 같이 기존 밧데리를 제거하고 밧데리 연결 상태를 잘 확인하여 홀더에 케이블을 연결했다. 홀더 때문에 공간이 커져서 청소기의 기존 밧데리가 있던 부분의 불필요한 부분을 제거하고 홀더에 밧데리를 넣고 결합했다.

제대로 동작하는지 확인하기 위하여 전원을 켜보았다. 그런데 이런…..
한번 “틱”하더니 멈춰 버린다. 분명히 밧데리는 동일 사양이고 용량은 오히려 더 커졌는데 동작이 안된다.

혹시나 실수 했을까 ? 다시 원래 밧데리로 연결해 보니 잘 동작한다.

인터넷을 아무리 뒤져도 특별한 것을 찾을 수 없다. 그러던 중 18650 밧데리 사양과 관련한 문서를 발견했다. 거기는 LG 밧데리에 대한 모델과 사양에 대하여 설명하고 있었는데 눈에 띄는 단어가 있다.

“고방전”

쇼핑몰을 뒤져 보니 고방전용 밧데리를 따로 팔고 있다. 고방전 밧데리를 다시 구입하고 며칠을 기다려 다시 홀더에 밧데리를 삽입하고 연결해서 테스트해보았다.

ㅎㅎㅎㅎ

잘 동작한다. 미쳐 몰랐다. 청소기나 전자 담배등과 같이 고전력을 요구하는 경우에는 고방전 밧데리를 사용한다는 것을 …

이 것을 알고 나서 다시 인터넷을 찾아보니 전에는 보이지 않던 고방전 밧데리 관련 내용이 참 많기도 하다.

아래는 밧데리를 장착한 모습니다.

청소기등의 밧데리를 교체할 때는 반드시 고방전 밧데리를 구입하여 사용해야 한다.
아래는 이번에 구입한 밧데리의 사양이다.

Posted in 미분류 | Tagged , , , | 3 Comments

HP 오피스젯 프로 8720 이전 버전 카트리지, 재생 카트리지 오류 해결 방법

인터넷에서 952XL 잉크를 구입해서 카트리지를 교체하고 사용하려는데…

갑자기 “이전 버전 카트리지”, “재생카트리지” 하면서 인쇄가 되지 않는다.

여기저기 검색하다 보니 구입한 프린터가 병행 수입 제품이고 자동으로 펌웨어 업데이트가 실행되도록 설정이 되어 있어서 펌웨어가 최신 버전으로 갱신되면서 문제가 발생한 것이었다.

해결 방법을 검색해보니 펨웨어를 다운그레이드 해야 한다고 한다.
HP 사이트에 가보니 최신 버전만 덩그러니 있다. 구버전은 다운 받을 수 있는 방법이 없다.
포기할 수 없다. 키워드를 바꾸어 가면 찾아보니 역시 있다. ㅎㅎㅎ

아래로 스크롤해보니 오피스젯 프로 8720 버전도 있다.

링크를 클릭하여 다운로드하고 압축을 풀었다.

실행 파일을 실행하니 자동으로 프린터를 찾아서 표시해 준다. 아래 url 을 찾아가면 자세한 설치 방법이 소개되어 있다. 또한 펌웨어 다운로드 링크도 있고 펌웨어 자동 업데이트를 끄는 방법에 대한 링크도 같이 있다.

How to Downgrade HP 952XL Printer Firmware (ldproducts.com)

설치가 끝나고 자동으로 두장의 헤드 정열 설정 페이지가 출력된다.

다시 펌웨어 업데이트를 하지 않도록 “오피스젯 프로 8720 펌웨어 업데이트 끄기” 로 검색하여 나오는 링크의 방법대로 업데이트 끄기를 설정한다. 관련 링크는 유튜브를 포함여 많이 나온다.

이제는 프린터를 정상적으로 사용할 수 있다.

Posted in 컴퓨터일반 | Leave a comment

WSASend() 에서 갑자기 Error code ‘6’을 리턴한다.

어느날 갑자기 잘 돌아 가던 코드가 장애를 일으킨다. 분명히 어제까지 잘 동작하던 코드인데….

소스 코드를 한달전까지 롤백도 해보고 별짓을 다했는데 안된다.

MSDN 을 수 없이 뒤져도 잘 모르겠다.

디버깅에 디버깅을 계속하다가 WSASend의 6번째 파라미터에 우연히 마우스 커서가 갔다.
순간 표시되는 COVERLAPPED * 구조체의 overlapped 멤버의 값이 0xdddddddd 이다.

아차 하는 느낌도 있었지만 그동안 잘돌기는 했는데….
혹시나 하는 마음에 아래와 같이 초기화를 해보았다.

.h 선언
	COverlapped		m_SendOV;
	COverlapped		m_RecvOV;	

.cpp 구현
	memset(&m_RecvOV, 0, sizeof(m_RecvOV));
	memset(&m_SendOV, 0, sizeof(m_SendOV));

ㅎㅎㅎㅎㅎㅎㅎ

참~~~
허탈하다….

그동안은 왜 잘동작했을까?
Windows 를 업그레이드 하면서 MS가 값의 검사를 좀더 꼼꼼하게 한 모양입니다.
error no 6 은 잘못된 핸들인데 소켓이 잘못된 것이라는 메시지로 잘못 인식한 것이죠. 여기서 잘못된 핸들은 초기화가 없어서 쓰레기값이 설정된 overlapped의 hEvent handle 이었던 것입니다. 또 한번 크게 느끼지만 초기화는 잘해야 할 것 같습니다.

그렇게 안보이던 초기화 관련된 내용이 이젠 보이네요. ㅎㅎㅎ
혹시라도 초기화가 빠진 부분이 있는지 다시 전체 소스를 검토하는 계기가 되었습니다.

저와 같은 실수 하지 마세요 ~~~

Posted in Window Program | Tagged | Leave a comment

이제 해킹은 그만 ~~~

log 파일을 보면 정말 빈번하게 외부에서 로그인을 시도하고 있다.
그렇다고 외부로 부터의 모든 접속을 차단할 수 도 없다.
이 참에 log 파일에서 인증 실패한 접속 ip 를 모두 차단하기로 작정하고 프로그램을 작성하려고 ms code를 열었다가 혹시나 하는 마음에 아래 키워드로 구글링을 해보았다.

ubuntu auto block ip authentication failure smtp ssh

역시나 이런 생각은 나만이 아니었다. fail2ban 이라는 어플리케이션이 이미 있다.
더구나 설치 예제 사이트로 엄청 많다. 설치도 쉽고 설정도 쉽다.

> sudo apt install fail2ban

이 한문장으로 끝이다. 설정은 구글링하면 너무나 쉽게 나온다. 기본 설정인 jail.conf 는 건드리지 않고 jail.local 를 만들어 내게 필요한 설정을 한다.

아래는 내게 필요한 smtp 관련된 설정과 80과 443을 열고 있으므로 혹시나 해서 이 것도 감시 대상에 추가했다. ssh, ftp, telnet 등은 외부에 개방하지 않았으므로 감시 대상에서 제외하였다.
그리고 너무 많은 감시 대상을 추가하니 fail2ban 이 실행하는 도중에 정지하는 상황이 발생한다. 감시 대상이 많아서 그런지 아니면 설정상 문제가 있는지는 확인하지 않았다. 단지, 내게 필요한 설정 만으로 정상 동작하고 있기 때문이다.

[DEFAULT]
banaction=ufw

bantime = -1
findtime = 6h

[roundcube-auth]
enabled = true

[postfix]
enabled = true

[postfix-rbl]
enabled = true

[sendmail-auth]
enabled = true

[apache-auth]
enabled = true

[apache-badbots]
enabled = true

[apache-noscript]
enabled = true

[apache-overflows]
enabled = true

[postfix-sasl]
enabled = true

"banaction=ufw" 는 방화벽을 ufw를 사용하도록 설정한 것이다. 기본이 iptables 이므로 iptables를 방화벽으로 사용하고 있으면 이 줄은 삭제하면 된다.
"bantime=-1"은 블록킹하는 시간을 의미한다. -1 은 영원히 블록하라는 의미이다.
"findtime=6h" 는 6시간 동안 인증실패가 5회이상 발생하면 블록리스트에 추가하라는 의미이다.
실패횟수는 maxretry로 설정할 수 있다. 기본은 5 회이다.

다른 부분은 내게 필요한 어플리케이션에 대하여 감시할 것인지를 설정하는 것이다. 가능한 어플리케이션의 종류는 jail.conf 에 다 들어 있다. 그 목록에서 내게 필요한 것만 가져와서 jail.local 에 기록하고 “[app-name] ” 만 남기고 다른 설정은 삭제한 후에 "enabled = true" 만 추가한다.

잠깐 사이에 아래와 같이 블록되는 IP 가 나타난다. ^^

root@mail:/etc/fail2ban# fail2ban-client status postfix-sasl
Status for the jail: postfix-sasl
|- Filter
|  |- Currently failed: 0
|  |- Total failed:     10
|  `- File list:        /var/log/mail.log
`- Actions
   |- Currently banned: 3
   |- Total banned:     3
   `- Banned IP list:   45.142.120.84 212.70.149.54 45.142.120.87
root@mail:/etc/fail2ban#

auth.log 를 보면 더이상 인증 실패 로그가 나타나지 않는다. ^^
이제 해킹으로 부터 조금은 더 안전한 사이트가 된 것 같다. ㅎㅎ


주1) fail2ban을 실행 할 때 “roundcube-auth” 에서 계속 실패를 한다. 로그를 보니 roundcube 로그 파일을 찾을 수 없다고 메시지가 표시된다.
“logpath = %(roundcube_errors_log)s” 에 해당하는 정의를 paths-debian.conf 에서 찾아 보니 정의가 없다. 그래서 아래와 같이 추가하고 다시 실행하니 정상적으로 잘 동작한다.

roundcube_errors_log = /var/log/roundcube/errors.log

이렇게 철저하게 방어하다 보니 아차 실수하면 나도 차단되고 만다. 이렇게 내가 차단된 경우에 나를 다시 해제하는 방법이 필요하다.

다음과 같이 한다.

fail2ban-client set <sshd:jail name> unbanip <ip address list>

위에서 jail name은 sshd, roundcube-auth 등과 같이 환성파일에서 설정한 jail의 이름이다. 마지막에 붙는 ip address list 는 jail에서 해제하기 위한 ip address 를 공백을 구분자로 하여 지정한다.

Posted in 리눅스 | Tagged , | Leave a comment

ubuntu에서 dig: parse of /etc/resolv.conf failed 오류 발생 시 …

일반적인 dns 관련 동작은 정상인데 dig 에 대해서만 제목과 같은 에러가 발생한다.
/etc/resolv.conf의 내용은 다음과 같다.

search spacek.xyz
nameserver localhost
nameserver 219.250.36.130
nameserver 168.126.63.1

특별히 문제가 없어 보이는데….
localhost 가 맘에 걸린다. 실제 주소로 변경하자 정상적인 동작을 보여준다.

아래는 수정된 resolv.conf 이다.

search spacek.xyz
nameserver 192.168.3.5
nameserver 219.250.36.130
nameserver 168.126.63.1

dig 명령에 아래와 같이 정상적으로 동작한다.

root@mail:/etc/bind/zones# dig spacek.xyz

; <<>> DiG 9.16.1-Ubuntu <<>> spacek.xyz
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34360
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 0f68e299b00cb9c2010000005fec6a34b2b89e3ca65ef332 (good)
;; QUESTION SECTION:
;spacek.xyz.                    IN      A

;; ANSWER SECTION:
spacek.xyz.             600     IN      A       58.229.145.135

;; Query time: 5 msec
;; SERVER: 192.168.3.5#53(192.168.3.5)
;; WHEN: Wed Dec 30 20:53:24 KST 2020
;; MSG SIZE  rcvd: 83
Posted in 리눅스 | Tagged , | Leave a comment

Ubuntu에서 Postfix, Dovecot, Roundcube 설정

해킹을 당한 후 다시 서버를 설정하고 있다. 메일서버를 설정하면서 ssl 을 사용하여 구성하기로 작정하고 아래 사이트를 참고하여 설정을 완료하였다.

하지만 문제가 있다. 다 잘되었지만 SMTP 전송에서 계속 에러가 발생한다.
mail.log 에는 다음과 같은 로그가 쌓인다.

Dec 27 11:47:46 mail postfix/submission/smtpd[10992]: connect from unknown[192.168.xxx.xxx]
Dec 27 11:47:46 mail postfix/submission/smtpd[10992]: lost connection after CONNECT from unknown[192.168.xxx.xxx]
Dec 27 11:47:46 mail postfix/submission/smtpd[10992]: disconnect from unknown[192.168.xxx.xxx] commands=0/0

tcpdump를 보니 다음과 같은 에러가 표시된다.
500 5.5.2 Error: Bad UTF-8 Syntax

아무리 비슷한 에러를 검색해봐도 해결 방법이 보이지 않는다. 꼼꼼이 설정을 뒤져 보다가 혹시나 하는 생각에 설정 하나를 바꾸어 보았다.

된다. ^^

아마도 위의 2번째 링크에서 실수가 있었던 것 같다. 좌우간 모든 것은 동일한 것 같은데 나는 안되었다. 하지만 이제 변경한 설정으로 잘 동작한다. ^^
변경한 내용은 Postfix/main.cf 의 내용이다. 아래와 같이 한 줄을 설정 파일 끝에 추가한다.

smtpd_use_tls=yes

위의 링크에서는 This parameter is for legacy Postfix (Versions before 2.3 ) 이라고 설명을 달고 Comment로 막아 놓았다. 하지만 나는 SSL을 사용하려고 하고 있으므로 당연히 TLS 가 활성화 되어야 한다. 따라서 이 설정이 yes 가 되어야 할 것 같다는 생각이 들어 혹시나 하는 마음으로 바꾸어 보았더니 제대로 동작하는 것이다.

혹시라도 또 해킹을 당해 서버가 망가지는 상황에서 잘 복구하기 위해 설정 내용을 잊지 않게 잘 보관해야겠다.

Posted in 리눅스 | Tagged , | Leave a comment

Ubuntu 에서 CertBot을 사용하여 무료 SSL 서버 구축하자

사용기간이 제한된 무료 상업용 ssl 인증서를 사용하거나 Self 인증서를 사용하여 보았지만 무료 기간이 지나면 사용하지 못하고 사설 인증서는 브라우저에서 제대로 사용하기가 어려웠다.

해결 방법을 찾다가 CertBot을 이용하여 자동으로 갱신까지 해준다는 내용을 보고 적용해보았다. 그런데 뜻밖에도 크롬 브라우저에서 별도의 경고 메시지도 없이 https 로 바로 조회가 된다.

마치 횡재를 한 기분으로 참조한 사이트를 소개한다. 아래 url link가 참조한 원본 사이트 이다. 가끔 사이트가 사라지거나 닫히는 경우가 있어 페이지의 내용을 복사해 놓는다. 이 내용을 참조하고자 한다면 아래 링크를 클릭해서 원본을 참조하기 바란다.
아래 복사한 내용은 백업을 위하여 복사한 것으로 포맷도 불량이고 원본 보다 보기가 좋지 않다.

https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04

Introduction

Let’s Encrypt is a Certificate Authority (CA) that facilitates obtaining and installing free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers. It simplifies the process by providing a software client, Certbot, that attempts to automate most (if not all) of the required steps. Currently, the entire process of obtaining and installing a certificate is fully automated on both Apache and Nginx.

In this guide, we’ll use Certbot to obtain a free SSL certificate for Apache on Ubuntu 20.04, and make sure this certificate is set up to renew automatically.

This tutorial uses a separate virtual host file instead of Apache’s default configuration file for setting up the website that will be secured by Let’s Encrypt. We recommend creating new Apache virtual host files for each domain hosted in a server, because it helps to avoid common mistakes and maintains the default configuration files as a fallback setup.

Prerequisites

To follow this tutorial, you will need:

  • One Ubuntu 20.04 server set up by following this initial server setup for Ubuntu 20.04 tutorial, including a sudo non-root user and a firewall.
  • A fully registered domain name. This tutorial will use your_domain as an example throughout. You can purchase a domain name on Namecheap, get one for free on Freenom, or use the domain registrar of your choice.
  • Both of the following DNS records set up for your server. You can follow this introduction to DigitalOcean DNS for details on how to add them.
    • An A record with your_domain pointing to your server’s public IP address.
    • An A record with www.your_domain pointing to your server’s public IP address.
  • Apache installed by following How To Install Apache on Ubuntu 20.04. Be sure that you have a virtual host file for your domain. This tutorial will use /etc/apache2/sites-available/your_domain.conf as an example.

Step 1 — Installing Certbot

In order to obtain an SSL certificate with Let’s Encrypt, we’ll first need to install the Certbot software on your server. We’ll use the default Ubuntu package repositories for that.

We need two packages: certbot, and python3-certbot-apache. The latter is a plugin that integrates Certbot with Apache, making it possible to automate obtaining a certificate and configuring HTTPS within your web server with a single command.

sudo apt install certbot python3-certbot-apache

Copy

You will be prompted to confirm the installation by pressing Y, then ENTER.

Certbot is now installed on your server. In the next step, we’ll verify Apache’s configuration to make sure your virtual host is set appropriately. This will ensure that the certbot client script will be able to detect your domains and reconfigure your web server to use your newly generated SSL certificate automatically.

Step 2 — Checking your Apache Virtual Host Configuration

In order to be able to automatically obtain and configure SSL for your web server, Certbot needs to find the correct virtual host within your Apache configuration files. Your server domain name(s) will be retrieved from the ServerName and ServerAlias directives defined within your VirtualHost configuration block.

If you followed the virtual host setup step in the Apache installation tutorial, you should have a VirtualHost block set up for your domain at /etc/apache2/sites-available/your_domain.conf with the ServerName and also the ServerAlias directives already set appropriately.

To check this up, open the virtual host file for your domain using nano or your preferred text editor:

sudo nano /etc/apache2/sites-available/your_domain.conf

Copy

Find the existing ServerName and ServerAlias lines. They should look like this:/etc/apache2/sites-available/your_domain.conf

...
ServerName your_domain
ServerAlias www.your_domain
...

Copy

If you already have your ServerName and ServerAlias set up like this, you can exit your text editor and move on to the next step. If you’re using nano, you can exit by typing CTRL+X, then Y and ENTER to confirm.

If your current virtual host configuration doesn’t match the example, update it accordingly. When you’re done, save the file and quit the editor. Then, run the following command to validate your changes:

sudo apache2ctl configtest

Copy

You should get a Syntax OK as a response. If you get an error, reopen the virtual host file and check for any typos or missing characters. Once your configuration file’s syntax is correct, reload Apache so that the changes take effect:

sudo systemctl reload apache2

Copy

With these changes, Certbot will be able to find the correct VirtualHost block and update it.

Next, we’ll update the firewall to allow HTTPS traffic.

Step 3 — Allowing HTTPS Through the Firewall

If you have the UFW firewall enabled, as recommended by the prerequisite guides, you’ll need to adjust the settings to allow HTTPS traffic. Upon installation, Apache registers a few different UFW application profiles. We can leverage the Apache Full profile to allow both HTTP and HTTPS traffic on your server.

To verify what kind of traffic is currently allowed on your server, you can use:

sudo ufw status

Copy

If you have followed one of our Apache installation guides, your output should look something like this, meaning that only HTTP traffic on port 80 is currently allowed:

OutputStatus: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
Apache                     ALLOW       Anywhere             
OpenSSH (v6)               ALLOW       Anywhere (v6)             
Apache (v6)                ALLOW       Anywhere (v6)

To additionally let in HTTPS traffic, allow the “Apache Full” profile and delete the redundant “Apache” profile:

sudo ufw allow 'Apache Full'
sudo ufw delete allow 'Apache'

Copy

Your status will now look like this:

sudo ufw status

Copy

OutputStatus: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
Apache Full                ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
Apache Full (v6)           ALLOW       Anywhere (v6)        

You are now ready to run Certbot and obtain your certificates.

Step 4 — Obtaining an SSL Certificate

Certbot provides a variety of ways to obtain SSL certificates through plugins. The Apache plugin will take care of reconfiguring Apache and reloading the configuration whenever necessary. To use this plugin, type the following:

sudo certbot --apache

Copy

This script will prompt you to answer a series of questions in order to configure your SSL certificate. First, it will ask you for a valid e-mail address. This email will be used for renewal notifications and security notices:

OutputSaving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): you@your_domain

After providing a valid e-mail address, hit ENTER to proceed to the next step. You will then be prompted to confirm if you agree to Let’s Encrypt terms of service. You can confirm by pressing A and then ENTER:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

Next, you’ll be asked if you would like to share your email with the Electronic Frontier Foundation to receive news and other information. If you do not want to subscribe to their content, type N. Otherwise, type Y. Then, hit ENTER to proceed to the next step.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N

The next step will prompt you to inform Certbot of which domains you’d like to activate HTTPS for. The listed domain names are automatically obtained from your Apache virtual host configuration, that’s why it’s important to make sure you have the correct ServerName and ServerAlias settings configured in your virtual host. If you’d like to enable HTTPS for all listed domain names (recommended), you can leave the prompt blank and hit ENTER to proceed. Otherwise, select the domains you want to enable HTTPS for by listing each appropriate number, separated by commas and/ or spaces, then hit ENTER.

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: your_domain
2: www.your_domain
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 

You’ll see output like this:

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for your_domain
http-01 challenge for www.your_domain
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/your_domain-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/your_domain-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/your_domain-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/your_domain-le-ssl.conf

Next, you’ll be prompted to select whether or not you want HTTP traffic redirected to HTTPS. In practice, that means when someone visits your website through unencrypted channels (HTTP), they will be automatically redirected to the HTTPS address of your website. Choose 2 to enable the redirection, or 1 if you want to keep both HTTP and HTTPS as separate methods of accessing your website.

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

After this step, Certbot’s configuration is finished, and you will be presented with the final remarks about your new certificate, where to locate the generated files, and how to test your configuration using an external tool that analyzes your certificate’s authenticity:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://your_domain and
https://www.your_domain

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=your_domain
https://www.ssllabs.com/ssltest/analyze.html?d=www.your_domain
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/your_domain/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/your_domain/privkey.pem
   Your cert will expire on 2020-07-27. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Your certificate is now installed and loaded into Apache’s configuration. Try reloading your website using https:// and notice your browser’s security indicator. It should point out that your site is properly secured, typically by including a lock icon in the address bar.

You can use the SSL Labs Server Test to verify your certificate’s grade and obtain detailed information about it, from the perspective of an external service.

In the next and final step, we’ll test the auto-renewal feature of Certbot, which guarantees that your certificate will be renewed automatically before the expiration date.

Step 5 — Verifying Certbot Auto-Renewal

Let’s Encrypt’s certificates are only valid for ninety days. This is to encourage users to automate their certificate renewal process, as well as to ensure that misused certificates or stolen keys will expire sooner rather than later.

The certbot package we installed takes care of renewals by including a renew script to /etc/cron.d, which is managed by a systemctl service called certbot.timer. This script runs twice a day and will automatically renew any certificate that’s within thirty days of expiration.

To check the status of this service and make sure it’s active and running, you can use:

sudo systemctl status certbot.timer

Copy

You’ll get output similar to this:

Output● certbot.timer - Run certbot twice daily
     Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset: enabled)
     Active: active (waiting) since Tue 2020-04-28 17:57:48 UTC; 17h ago
    Trigger: Wed 2020-04-29 23:50:31 UTC; 12h left
   Triggers: ● certbot.service

Apr 28 17:57:48 fine-turtle systemd[1]: Started Run certbot twice daily.

To test the renewal process, you can do a dry run with certbot:

sudo certbot renew --dry-run

Copy

If you see no errors, you’re all set. When necessary, Certbot will renew your certificates and reload Apache to pick up the changes. If the automated renewal process ever fails, Let’s Encrypt will send a message to the email you specified, warning you when your certificate is about to expire.

Conclusion

In this tutorial, you’ve installed the Let’s Encrypt client certbot, configured and installed an SSL certificate for your domain, and confirmed that Certbot’s automatic renewal service is active within systemctl. If you have further questions about using Certbot, their documentation is a good place to start.

Posted in 리눅스 | Tagged , , | Leave a comment

WSL/Ubuntu에 작업 환경 설정하기

  • C++ 개발환경 설정하기
apt update
apt upgrade
apt install build-essential gdb
// 설치 및 버전 확인
g++ --version
  • Windows Directory mount 하기
# windows folder를 mount 할 로컬 경로 생성
mkdir /<localdir>
# 그룹을 만들고 사용자 id 추가
sudo groupadd <localGroup>
sudo usermod -aG <localGroup> <userid>
sudo chown -R :<localGroup> /<localDir>
# fstab 에 mount 설정 추가
cat /etc/fstab
LABEL=cloudimg-rootfs / ext4 defaults 0 0
/mnt/c/_Work/<WindowWorkingFolder> /<localDir> auto nosuid,nodev,nofail,bind 0 0
# 자동으로 마운트 되도록 설정 'mount -a' 를 추가 함. root user에 설정. 일반 사용자의 .bashrc 에 설정하는 경우 'sudo mount -a' 사용
vi .bashrc
mount -a
  • 디렉토리 이동을 위한 alias 설정하기
alias cds  ='cd /DirectoryPath1'
alias cdn  ='cd /DirectoryPath2'
alias cdsn ='cd /DirectoryPath3'
alias cdm  ='cd /DirectoryPath4'
alias cdl  ='cd /DirectoryPath5'
alias cdio ='cd /DirectoryPath6'
alias cdb  ='cd /DirectoryPath7'
alias cdns ='cd /DirectoryPath8'
alias cdsvc='cd /DirectoryPath9'
alias cdtr ='cd /DirectoryPath10'
alias cdc  ='cd /DirectoryPath11'
alias psg  ='ps -ef | grep '
  • Python 설치하기
apt install python3.8 python3-dev
  • WSL에 설치된 ubuntu Restart 하기
    • 윈도우에서 관리자 모드로 PowerShell을 실행한다.
    • Restart-Service LxssManager 을 실행한다.
  • 윈도우에 VScode 설치하기
    https://code.visualstudio.com/ 에서 다운로드
  • ubuntu에서 vscode 설정하기
    ubuntu의 임의 폴더에서 code . 실행하여 vscode 를 실행한다.
    “Remote WSL” extention 을 설치한다.
  • WSL uninstall
    wslconfig /u Ubuntu-20.04
  • .profile 설정
PATH=".:$PATH"
LD_LIBRARY_PATH=/ois/Lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

Posted in 리눅스 | Leave a comment

윈도우즈 10 에서 간단하게 WSL 을 설치하는 방법이다.

  • 관리자 모드로 PowerShell 을 실행한다.
    다음과 같이 명령어를 입력한다.
    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
  • WSL 2 로 업데이트
    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    설치한 내용이 적용되도록 윈도우를 재기동 합니다.
    재기동 후 다시 관리자 모드로 PowerShell 을 실행합니다.
  • WSL 2 를 기본으로 설정
    PowerShell 에서 wsl --set-default-version 2 을 입력합니다.
  • Ubuntu 설치하기
    아래 링크를 클릭하여 Linux 제품을 구매하는 윈도우 스토어를 엽니다.
    https://aka.ms/wslstore
    1. Ubuntu 를 선택하고 구매 및 설치합니다.
  • 설치가 완료되면 아래와 같이 최초 사용자를 등록하는 화면이 나옵니다.

최초 사용자를 입력하고 사용할 비밀번호를 설정하면 우분투의 설치가 완료됩니다.

Posted on by kimyc | Leave a comment