'Linux/Ubuntu'에 해당되는 글 4건

  1. 2021.03.21 Ubuntu 웹서버 구축
  2. 2021.03.20 Ubuntu VNC 설치
  3. 2021.03.17 Ubuntu Network & WOL
  4. 2021.03.16 Ubuntu 20.04 LTS Server 버전 설치
Linux/Ubuntu2021. 3. 21. 23:15

Ubuntu 18.04 LTS 에서 설치하는 방법은 이곳에 : https://blog.lael.be/post/7264

Ubuntu 14.04 LTS 에서 설치하는 방법은 이곳에 : https://blog.lael.be/post/4518  비밀번호 ubuntu 입니다.

 이 글은 Ubuntu 16.04 LTS 에 맞추어 작성되었습니다.

#16.10.04 무료 보안인증서(SSL) 적용방법이 추가됨

무료 보안인증서 설치방법이 추가되었습니다. HTTPS 사용을 원하신다면, 본문을 다 읽으신 후 다음의 글로 이동해주세요.

https://blog.lael.be/post/5107

 


이 문서는 2010년 4월 12일에 처음 쓰여졌으며, 주기적으로 업데이트/유지보수 되고 있습니다.

이 문서는 항상 최신버전(Edge Version)의 세팅법을 설명합니다.

 


이 글에서는 자동화되고 유지보수 관리되는 설치방법을 설명하고 있습니다.

아래의 방법대로 설치한 후에 언제든지

 

 

1

 

apt-get update

 

 

 

 

 

1

 

apt-get upgrade

 

 

 

명령을 사용하면, 항상 빠르고 안전한 최신버전의 서버 소프트웨어를 사용하실 수 있습니다.


* 이 글은 Ubuntu 에 PHP 웹서버를 세팅하는 방법을 소개하고 있습니다.

* PHP를 최신버전으로 구축하고 싶다면 https://blog.lael.be/post/2600 글로 이동하세요. (Nginx + PHP7-FPM + MariaDB)

- CentOS 에서 PHP 를 구축하고 싶다면 https://blog.lael.be/post/1721 (Apache + PHP + MariaDB)

* Ubuntu 에서 JSP 웹서버 세팅을 원하시면 https://blog.lael.be/post/858 글로 이동하세요.

* Ubuntu 에서 PHP와 JSP를 동시 구동하고 싶으시면 https://blog.lael.be/post/1023 글로 이동하세요.

* Ubuntu 가상서버호스팅을 찾는 중이라면 https://blog.lael.be/post/44 글로 이동하세요.


현재 배포된 Ubuntu 버전은 아래와 같습니다.

 


운영체제의 수명이 긴 LTS 버전을 설치하도록 합시다. (버전숫자가 높다고 더 좋다는 뜻은 아님)

 

Ubuntu 운영체제에 관해서는 http://en.wikipedia.org/wiki/Ubuntu_(operating_system) 를 참조하세요.

 

이 문서에서 설치는 Ubuntu 16.04 LTS를 기준으로 합니다. (14.04 와는 패키지가 약간 다를 수 있음)

참고로
Ubuntu 14.04 LTS 다운로드 이미지는 http://releases.ubuntu.com/14.04/ubuntu-14.04.5-server-amd64.iso 이며,
Ubuntu 16.04 LTS 다운로드 이미지는 http://releases.ubuntu.com/16.04/ubuntu-16.04.4-server-amd64.iso 입니다.

 

일반 사업체 및 실무 서비스에서 사용할 수 있는 안정적인 세팅법을 알려드리겠습니다.

 


0) root 권한으로 변경

기본으로 주어진 계정이 root 가 아닐 경우에만 0번을 따라하세요.
본문의 모든 명령어는 root 의 권한에서 실행해야합니다. 자신에게 주어진 계정이 root 계정이 아니라면 다음의 명령어로 root 로 전환해 주도록 합시다.

자신의 계정 보기

# whoami

sudo 명령어 실행. root 권한으로 root 로 로그인하는 명령어를 실행한다.

# sudo su

자신의 계정 보기

# whoami

 

 

기본 계정의 UserID 는 그림과 다를 수 있음. 위 예시에서 기본 아이디는 ubuntu 이다.

sudo 명령어를 사용할 수 있는 계정은 root 와 동급이니 비밀번호 관리에 신중해야한다. 기본 계정의 비밀번호를 매우긴 어려운 것으로 변경해주도록 하자.

# passwd ubuntu

 

 

 

1) 리눅스 버전체크

#uname -a Linux Lael-ubuntu-xenial 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

2) Ubuntu 버전체크

#cat /etc/issue Ubuntu 20.04.2 LTS \n \l

조금 더 자세하게 운영체제 버전정보를 알아보고 싶다면

# lsb_release -a

해당 명령어는 Ubuntu 에서는 기본적으로 설치되어 있지만 CentOS 계열에서는 기본패키지가 아니니 사용하려면 다음 명령어로 설치해주어야 합니다.

# yum install redhat-lsb-core

3) 하드용량체크

#df -h Filesystem Size Used Avail Use% Mounted on udev 2.0G 0 2.0G 0% /dev tmpfs 396M 6.2M 390M 2% /run /dev/vda1 85G 3.6G 77G 5% / tmpfs 2.0G 192K 2.0G 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup tmpfs 396M 92K 396M 1% /run/user/1000 tmpfs 396M 0 396M 0% /run/user/0

대략 다 더하면 90G가 나온다.

 

4) 메모리 체크

#free -m total used free shared buff/cache available Mem: 3951 770 2262 10 918 3116 Swap: 4093 0 4093

3951M의 전체메모리중 현재 770M을 사용하고 있고 3116M가 비어있다.

 

4-1) CPU 코어수 확인

cpu정보 프로세스를 읽어서 processor 항목이 몇개인지 갯수를 셉니다.

#cat /proc/cpuinfo | grep processor | wc -l

 

 

위의 사진은 6 core 를 뜻합니다.

한번 정도는 다음의 명령어를 확인해 보세요.

#cat /proc/cpuinfo | grep processor#cat /proc/cpuinfo

 



5) 현재 서버에 설치된 패키지 최신버전으로 업그레이드

APT 목록 갱신

APT란 Advanced Packaging Tool 을 뜻합니다.
우리는 apt 라는 우분투에 내장된 프로그램을 이용해서 프로그램을 쉽게 설치/제거 할 수 있습니다.

 

패키지 목록 갱신.

#apt-get update

 

현재 운영체제에 설치되어있는 프로그램 최신버전패치

#apt-get upgrade

6) 시스템 시간 설정

이것을 하지 않으면 영국 시간을 불러올 것이다.

물론 초기 설치할 때 Asia/Seoul 을 설정했다면 이 작업을 할 필요는 없다. 하지만 또 한다고 해서 문제되지는 않는다.

- 데비안 패키지 재설정 TimeZone Data 를 실행한다.

#dpkg-reconfigure tzdata

GUI 환경이 나올 텐데, 순서대로 Asia - Seoul 을 선택하면 된다.

 

 

 

 

 

 

7) Hostname 설정

이 서버에 이름을 정하는 것이다. 이름을 잘 정해 두어야 나중에 다중 서버작업을 할 때 헷갈리지 않는다.

 

 

위의 뜻은 “li599-115 서버에 root 사용자” 라는 뜻이다.

서버 이름은 FQDN(Fully Qualified Domain Name)을 쓰는 것이 좋다.

참고로 라엘이의 이 블로그 서버의 hostname은 blog.lael.be 이다.

 

#vi /etc/hostname

빈 파일일 건데(또는 기존 hostname이 쓰여있을것임.) 원하는 이름으로 바꾼다.

권장하는 단어는 이 서버에 연결될 대표 도메인이다. 예를 들어 blog.lael.be 같은 것.

 

적용한다.

#hostname -F /etc/hostname

 

서버에 재 접속하면 적용된 것을 확인 할 수 있을 것이다.

 

 

hostname 값은 서버작업자에게 서버이름을 알려주는 역할을 하며, 아무 의미없는 글자를 적어도 된다.

일부 sendmail 같은 프로그램에서 다른 서버와 통신시 사용하기도 한다.

 

- hostname 을 FQDN 으로 설정하는 것을 권장하지만, 외부와 연결이 없는 서버이거나 자신이 쓰고 싶은 이름이 있다면 (팀명이나, 회사명, 서비스명 등) 그것으로 해도 된다.

예를 들어 myserver1, new1111 같이 자신이 하고 싶은대로 정했다고 한다면, 서버의 /etc/hosts 에 해당 이름을 등록해두도록 하자.

hostname 이 유효한 도메인 네임일 경우에는 이 작업(/etc/hosts)을 건너뛰세요.

127.0.0.1    myserver1

 

 

 

추가) 메일 발송프로그램 설치하기

많은 프로그램에서 mail() 함수를 사용한다. 이 함수는 서버의 sendmail 프로그램에게 메일발송을 요청한다.

메일문의, 가입시 환영메일, 비밀번호 찾기 메일, 이메일인증 등 널리 사용된다. 서버가 메일 발송을 할 수 있게 sendmail 을 설치하자.

# apt-get install sendmail

이것은 오직 웹사이트에서 메일을 보내기 위한 것이다.

아이디@당신의도메인.com 같은 것을 하고 싶다면 절대로 직접 구축하려고 하지 말고 구글앱스, 도메인 구입처, 클라우드서버 업체의 메일호스팅, 서버호스팅업체의 메일호스팅 을 사용하도록 하자.

 

# vi /etc/mail/local-host-names

 

 

localhost 를 제외하고 나머지 항목은 지운다. 이곳에 쓰여진 도메인은 sendmail 발송시 목적 메일서버조회(mx record query)를 하지않고 로컬로 보낸다.

 

8) Apache2 설치

#apt-get install apache2

16.04 LTS 에서는 apache 2.4.x 가 설치된다. (2016년 4월 21일 현재 최신버전은 Apache 2.4.18 이다.)

가끔씩 apt-get update  apt-get upgrade 를 실행하면 아무런 문제없이 최신버전으로 업데이트 될 것이다.
설치가 완료되면 자동적용 및 시작된다.

버전체크

apache2 -v

 


확인해본다.
http://256.123.213.213 (서버의아이피)
웹브라우져에 기본 설명페이지가 뜨면 성공.
(참고로 기본으로 보여지는 파일은 /var/www/html/index.html 이다.)
기본 파일을 지운다.

 

#rm /var/www/html/index.html

기타 주로 사용되는 모듈을 활성화, 필요없는 모듈은 비활성화 한다.
아래 모듈에 대한 자세한 설명은… 생략한다.
사용에 문제가 발생하지 않는 최상의 방식이라고 이해하면 된다.

#a2enmod rewrite #a2enmod headers #a2enmod ssl #a2dismod -f autoindex

 


#추가 보안패치. (.git, .svn, .env 등 dot로 시작하는 파일 및 폴더 보호, Web Access가 되어서는 안될 파일들의 접근 제어)

# vi /etc/apache2/apache2.conf

파일 중간의 <FilesMatch “^\.ht”> 구문 다음에 추가한다.

 

 

/etc/apache2/apache2.conf 설정파일 중간에 추가

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

 

# deny file, folder start with dot

<DirectoryMatch "^\.|\/\.">

    Require all denied

</DirectoryMatch>

  

# deny (log file, binary, certificate, shell script, sql dump file) access.

<FilesMatch "\.(?i:log|binary|pem|enc|crt|conf|cnf|sql|sh|key|yml|lock|gitignore)$">

    Require all denied

</FilesMatch>

  

# deny access.

<FilesMatch "(?i:composer\.json|contributing\.md|license\.txt|readme\.rst|readme\.md|readme\.txt|copyright|artisan|gulpfile\.js|package\.json|phpunit\.xml|access_log|error_log|gruntfile\.js|bower\.json|changelog\.md|console|legalnotice|license|security\.md|privacy\.md)$">

    Require all denied

</FilesMatch>

 

# Allow Lets Encrypt Domain Validation Program

<DirectoryMatch "\.well-known/acme-challenge/">

    Require all granted

</DirectoryMatch>

 

 

 

 

 



 

9) PHP 7.4 설치

PHP 5 를 설치하고 싶으시면 Ubuntu 14.04 LTS 를 설치하세요.

--

#apt-get install php

 

 

20.04 에서는 PHP 7.4.x 가 설치된다.

 

PHP-아파치 연동모듈 설치

#apt-get install libapache2-mod-php7.4

 

기타 주로 사용되는 모듈을 설치한다.
- 암호화 모듈

#apt-get install php-mcrypt
computingforgeeks.com/install-php-mcrypt-extension-on-ubuntu/

 

- 다국어 처리모듈

#apt-get install php-mbstring

 

- 이미지처리 모듈

#apt-get install php-gd

 

- 원격지 정보 불러는 모듈 (워드프레스, 드루팔 등에서 쓰임)

#apt-get install php-curl php-xml

 

-추가로 설치하고 싶은 모듈이 있으면

#apt-cache search php-

라고 입력해서 설치가능한 패키지를 검색후 install 하도록 하자.

 

 

- 아파치 재시작(적용을 위해서)

#service apache2 restart

버전체크
#php -v

PHP 7.0.4-7ubuntu2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

7.0.4 버전이다. (당신이 설치한 버전은 이것보다 높을 것이다.)

 

10 - 1) MariaDB 설치

mysql 과 mariadb 는 완전 API 호환된다.

 

#apt-get install mariadb-server

MariaDB 10.0.24 이 설치된다.

 

MariaDB 초기화.

14.04 LTS까지는 자동으로 처리되던 작업인데.. 분리되었다.

아무튼 데이터베이스 초기화 작업을 하도록 하자.

다음의 명령어 실행하자.

/usr/bin/mysql_secure_installation

모르면 엔터 누르면 된다. (비밀번호만 설정하고 나머지는 엔터)

잘못한 것 같으면 위 명령어를 다시 실행하면 된다.

 

 

:: root 의 인증 플러그인 정보 제거하기

MySQL에 플러그인이라는 개념이 생겼다. 그 중 하나가 서버사이드 인증이다.

예를들어 Linux의 myuser1 사용자와 MySQL(MariaDB)의 myuser1 과 연결이 되는 경우이다. (비밀번호 필요없이 쉘인증)

root 사용자가 기본값으로 unix_socket Auth Plugin 이 설정되어 있는데… 이건 실 사용에 많은 불편함을 준다.  기존과 같이 비밀번호 인증 방식으로 바꾸도록 하자.

Linux root 사용자로 로그인한 상태에서

# mysql

(현재는 unix_socket 인증방식이라서 Linux root 사용자는 MySQL(MariaDB) root 계정에 비밀번호 없이 로그인 할 수 있다)

 

 

use mysql; update user set plugin='' where User='root'; flush privileges; exit;

 

-----------

 

#apt-get install php-mysql

DB 연동모듈 설치. 완전 호환되기 때문에 mysql 이라고 해도 mariadb 사용가능.

 

MYSQL 콘솔 클라이언트 버전체크
#mysql -V mysql
Ver 15.1 Distrib 10.0.24-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

 

 

10 - 2) 기본 언어셋 설정(중요)

이 단계를 건너뛰면 DB가 latin1 으로 생성되며 추후 DB작업에 문제가 생길 수 있다.

#vi /etc/mysql/mariadb.conf.d/50-server.cnf

 

(vi 에디터 사용방법을 모른다면 ftp 클라이언트를 사용하여 서버에 로그인 후 해당파일을 수정하고 덮어쓰기한다.)

 

[mysqld] 항목에 다음 2 줄을 추가한다.

2015년도 부터는 아래와 같이 utf8mb4 속성을 사용하세요.

이 속성은 utf8확장입니다. 기존의 모든 utf8과 상위 호환됩니다. (utf8 에서 utf8mb4 로의 변환은 손실이 일어나지 않습니다.)

 

utf8mb4 속성은 스마트폰 이모티콘 문자(emoji)를 저장할 수 있습니다.

자세한 설명은 이곳에(https://blog.lael.be/post/917) 있습니다.

 

 

/etc/mysql/mariadb.conf.d/50-server.cnf 에 추가

1

2

 

character-set-server = utf8mb4

collation-server = utf8mb4_unicode_ci

 

 

 

 

 

 

 

변경사항 적용

#service mysql restart

 

11) PHP 권한 설정

웹 서비스 구동시 발생할 수 있는 Nobody 퍼미션 관련 문제를 해결하기 위해 관련 프로그램을 설치한다.
이 세팅을 하면 shell의 권한과 sftp의 권한과 web의 권한이 동일하게 취급되며 보안도 좋게된다.
순서대로 쓰면 된다.

# apt-cache search mpm-itk

libapache2-mpm-itk - multiuser module for Apache

 

 

 

#apt-get install libapache2-mpm-itk
#chmod 711 /home
#chmod -R 700 /home/*

(/home/* 안에 아무파일도 없을 경우 마지막 구문은 에러가 날 수 있다. 에러가 나면 무시하도록 하자.)

 

11-1) PHP 실행확장자 변경

 

php 를 해석하는 확장자가 꽤 많이 있다.

#vi /etc/apache2/mods-available/php7.4.conf

 

 

.php .php3 .php4 .php5 .php7 .pht .phtml  확장자 파일이 기본적으로 php를 해석할 수 있게 되어있다.

웹페이지에서 파일업로드 구현시 이 확장자 파일을 제대로 막아주지 못하면 사이트가 위험하게 된다.

 

.php 를 제외한 나머지의 접근을 차단하자.

 

 

 

1

2

3

 

<FilesMatch ".+\.ph(p3|p4|p5|p7|t|tml)$">

    Require all denied

</FilesMatch>

 

 

 

 

 

 

--------------------------------------------

적용을 위해서 아파치 재시작

#service apache2 restart

 



11-2) PHP Default timezone 설정하기.

이 값을 설정하지 않으면 시스템 timezone 을 사용합니다.

PHP Default timezone 을 설정하는 것은 필수는 아니지만 매우 권장하는 작업입니다. 설정해주세요.

동일한 작업 2개의 파일에 적용해 주어야 합니다.
이건 Apache2 - PHP 일때 참조하는 설정파일입니다.

#vi /etc/php/7.4/apache2/php.ini

이건 Cron이나 Console에서 PHP를 직접실행할때 참조하는 설정파일입니다.

#vi /etc/php/7.4/cli/php.ini

 

date.timezone 값을 찾아서 주석을 제거하고 시간을 설정해주세요.

 

 

이 값을 찾아서

 

 

 

이렇게 변경.

 

#service apache2 restart

 

 

 

나중에 mytest.php 파일을 만들고 웹브라우져에서 실행시킨 뒤 위와 같이 설정되어 있으면 정상이다.

 

 

mytest.php

1

 

<?php phpinfo(); ?>

 

 

 

Default timezone 이 설정되어 있으면 정상.

 

 

12) 계정생성 및 동작테스트

원래 표준명령어는 useradd 이지만    ubuntu는 사용하기 좋게 adduser 를 지원한다.
리눅스 관련 서적을 보면 둘다 계정생성용 명령어라고 되어있다.
쉬운 설정을 위해 adduser를 사용

#adduser myuser1

(참고로 위와 반대동작을 하는 계정삭제 명령어는 - 계정을 삭제하고 홈디렉토리도 삭제함 -

#userdel -r myuser1

입니다.)

보통 웹루트는 홈디렉토리에 하지 않습니다.
저는 주로 www 디렉토리를 사용합니다.사용자변경 후 www 디렉토리를 생성하고 빠져나오기

#su -l myuser1
#mkdir www
#exit

13) 웹사이트 Apache 환경설정파일 작성

#16.12.20 설정 가이드가 추가됨

환경설정을 쉽게하도록 도와주는, 환경설정 생성기가 추가되었습니다.

https://webmaster.cafe/tools/apache-conf-generator/

 

다음의 내용을 작성한다.
아래 예제에서는 사이트 환경설정파일명을 lael.be 로 가정하고 진행한다.
당신의 도메인, 사용자 아이디, 별도의 구분단어로 설정해서 사용하도록 하자.

#vi /etc/apache2/sites-available/lael.be.conf

/etc/apache2/sites-available/lael.be.conf 에 저장한다.

 

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

 

<VirtualHost *:80>

    #main domain

    ServerName lael.be

 

    #additional domain

    ServerAlias www.lael.be

    ServerAlias my-anotherdomain.com

 

    #document Root

    DocumentRoot /home/myuser1/www/

 

    #additional setting

    <Directory /home/myuser1/www/>

        Options FollowSymLinks MultiViews

        AllowOverride All

        require all granted

    </Directory>

 

    AssignUserID myuser1 myuser1

 

    ErrorLog ${APACHE_LOG_DIR}/lael.be-error.log

    CustomLog ${APACHE_LOG_DIR}/lael.be-access.log combined

</VirtualHost>

 

 

 

ServerAlias 는 사용안하면 빼도 되는 줄이다.

#15.09.16 추가

당신이 만약 SSL(https) 를 적용하고자 한다면 lael.be.conf 파일 하단에 다음의 코드를 추가하세요. 즉 VirtualHost 영역을 하나 더 추가.

 

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

 

<VirtualHost *:443>

    #main domain

    ServerName lael.be

 

    #additional domain

    ServerAlias www.lael.be

    ServerAlias my-anotherdomain.com

 

    #document Root

    DocumentRoot /home/myuser1/www/

 

    #additional setting

    <Directory /home/myuser1/www/>

        Options FollowSymLinks MultiViews

        AllowOverride All

        require all granted

    </Directory>

 

    AssignUserID myuser1 myuser1

 

    ErrorLog ${APACHE_LOG_DIR}/lael.be-error.log

    CustomLog ${APACHE_LOG_DIR}/lael.be-access.log combined

 

    Header always set Strict-Transport-Security "max-age=31536000"

 

    SSLEngine on

 

    SSLProtocol all -SSLv2 -SSLv3

 

    SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA

 

    SSLHonorCipherOrder on

 

    SSLCertificateFile "/home/myuser1/ssl/mysite_ssl.crt"

    SSLCertificateKeyFile "/home/myuser1/ssl/mysite_ssl.key"

    SSLCertificateChainFile "/home/myuser1/ssl/mysite_ssl.certchain.crt"

 

</VirtualHost>

 

 

 

https://www.sslshopper.com/ssl-checker.html#hostname=blog.lael.be  (SSL Chain test - 인증서가 올바르게 설치되어 있는지)

https://www.ssllabs.com/ssltest/analyze.html?d=blog.lael.be (SSL Algorithm test - 안전한 암호화 통신이 설정되어 있는지)

Chain test  모두 Valid 이어야하고, SSL Algorithm test  A 이상이면 정상적인 운영이 가능하다.

라엘이가 여러 설정 값에 대해서 테스트를 해 보았고, 최적의 권장설정 값을 위와 같이 적어두었으니 그대로 쓰면 된다.

위의 설정값으로 SSL을 설치하면 A+등급을 받을 수 있을 것이다.

 

 

 

.

인증서 적용 테스트는 위의 사이트를 이용하여라.

인증서 체인 파일이란 “인증서에 대한 인증서” 파일이다.

 

 

< 그림 : 이 블로그는 위의 단계를 거쳐 인증된다. 이것을 체인 인증 이라고 한다. >

대통령이 당신을 인증할 때 직권으로 인증하는 것이 아니라, 대통령 -> 서울시장 -> 강남구청장 -> 삼성동장 -> 당신 의 단계를 거친다. 검증하려면 모든 단계의 보증 증서를 제공해야 하는 것이다.

인증서 파일에는 삼성동장 -> 당신  의 정보가 들어있고, (암호화 통신시 공개됨)

인증서 키 파일에는 암호화 통신을 위한 정보가 들어있고 (은행 보안카드 로 비유. 외부에 공개되지 않음.)

인증서 체인 파일에는 대통령 -> 서울시장, 서울시장 -> 강남구청장, 강남구청장 -> 삼성동장 의 정보가 들어있다. (체인 인증이라고 한다. 연결고리 인증)

인증서 체인을 올바르게 작성하지 않으면 Firefox 브라우저 Android Chrome 브라우저에서 “인증서 정보부족” 오류가 발생하게 된다.

 

14) 사이트 활성화 및 적용

명령어는
#a2ensite 사이트환경설정파일명
입니다.

#a2ensite lael.be

(참고로 사이트 비활성화는

#a2dissite lael.be

입니다.)

- 아파치 설정 다시 불러오기(적용을 위해)

#service apache2 reload


 

15) 연동테스트

apache 와 php, 그리고 mariadb 를 모두 사용하는 프로그램을 실행시켜보자.

phpmyadmin 공식사이트 : https://www.phpmyadmin.net/

 

설치 못하시는 분이 꽤 있으셔서 따로 설치법을 적습니다.

여러 설치방법이 있겠지만 저는 다음과 같이 설치합니다.

 

압축해제 프로그램 설치# apt-get install unzip

 

압축파일 다운로드# cd /var/www/html

 

 

 

https://www.phpmyadmin.net/ 사이트로 이동 후 위의 그림과 같이 입력하여 최신버전을 설치할 수 있도록 하자.

이 글에서는 글 작성 시각 현재 최신버전인 4.5.2 를 설치할 것이다. phpmyadmin 은 매우 견고하게 만들어진 프로그램으로써 4.5.2를 설치해도 보안취약점이 있지는 않겠지만 최신버전을 설치하는 습관을 기르도록 하자. (혹시나 말하지만, Alpha나 Beta 같은 개발자-최신버전을 설치하라는 뜻이 아니라 널리 사용되어 검증된 Release Channel 최신버전 를 사용하라는 것이다.)

# wget https://files.phpmyadmin.net/phpMyAdmin/4.5.2/phpMyAdmin-4.5.2-all-languages.zip

 

압축해제

# unzip phpMyAdmin-4.5.2-all-languages.zip

 

폴더 이름변경

# mv phpMyAdmin-4.5.2-all-languages phpMyAdmin

 

다운받은파일 삭제

# rm phpMyAdmin-4.5.2-all-languages.zip

도메인주소 말고 서버의 아이피를 입력해야 기본사이트로 들어갈 수 있다.

만약 기본사이트 이외의 사이트에 설치하고 싶다면 /var/www/html 위치 대신 /home/myuser1/www 같은 곳에 phpmyadmin 코드를 넣도록 하자.

http://111.222.333.444/dbmyadmin/

 

 

 

[TIP] 간혹 방금 설치한 디비의 root 비밀번호가 기억이 안나는 분들도 있을 것이다. 이 경우에는 다음의 명령어를 사용하여 mariadb 를 재설치 하도록 하자.
- 제거
# apt-get purge mariadb-server
- 설치
# apt-get install mariadb-server

 

 

- 재부팅

복잡한 세팅이 끝났으니 한번 숨을 고르고 가자.

# reboot

재부팅 후에 phpinfo 페이지와 phpmyadmin 가 잘 실행된다면 “재부팅이 가능한 서버” 라고 볼 수 있다.

 

16) Apache 추가 보안 설정

- 기본 언어셋 설정

#vi /etc/apache2/conf-available/charset.conf

기본 언어값 UTF-8 에 대해서 주석처리되어 있을 텐데 주석(#)을 제거해 준다.

 

 

 

- 추가 보안 설정

#vi /etc/apache2/conf-available/security.conf

매우 권장하는 보안설정이므로 Ubuntu Apache 패키지 제작자가 미리 써두었다.
이미 다 쓰여 있으니까 주석(#) 만 제거하자.

 

 

 

 

 

 

 

- 아파치 설정 다시 불러오기(적용을 위해)

#service apache2 reload




옵션) SSH 기본 포트번호 변경

#이 작업은 무작위 대입공격(Brutu force attack)의 시도를 차단해줍니다.
보통 IP주소 : 22번 포트를 스캔해서 ssh와 연결되면 무작위 로그인 시도를 하는 프로그램이 엄청 많은데,
포트번호만 바꾸어주어도 방어가 되거든요.

!! IPTABLES 방화벽, SSH 포트번호 변경, Fail2ban 중에서 하나만 적용하세요!!

1) 나는 KS 클라우드 or 아마존 클라우드를 사용하고 있어! -> 클라우드 방화벽 쓰세요 !!
2) 나는 허용된 IP만 서버에 접속하게 할거야 -> IPTABLES !!
3) 나는 사용자의 IP를 특정지을 수 없는데 무차별대입 공격은 방어할거야 -> Fail2ban !!
4) 나는 나만 아는 포트번호로 서버에 접속할 거야 -> SSH 포트변경!!

[개인 프로젝트, 회사의 서비스 -> IPTABLES]
[웹호스팅 -> Fail2ban 또는 SSH 포트변경]

SSH 기본 포트번호인 22번을 다른 번호로 바꿉니다.
기억하기 쉬운 숫자로 변경하세요.

 

#vi /etc/ssh/sshd_config

Port 22   를 찾아서 임의의 숫자 : 10022, 34522 등 기억하기 쉬운 숫자로 설정.

포트번호는 10000번 이상의 숫자를 선택하시길 권장합니다.

 

#service ssh restart

 


 

옵션) 방화벽 적용하기

방화벽의 중요성을 알고 싶다면

# tailf /var/log/auth.log

를 입력해보도록 하자.  (Control + C 를 눌러 프로그램 종료)

별도의 방화벽 설정이 없었다면 벌써 중국에서 서버에 로그인 시도를 하고 있을 것이다.

 

 

이러한 무차별 로그인 시도를 다음 중 어느 하나를 사용해서 막을 수 있다.

가장 편한 것은 fail2ban 이다. (한줄만 타이핑하면 방어됨)
(https://blog.lael.be/post/858#fail2ban) 로 이동해서 설정하세요.
* 접속자의 IP 가 고정되어 있으면 방화벽 설정을 통해, 특정 아이피에서만 서버에 접속할 수 있도록 설정해주세요.

 

현재 방화벽 설정 보기. (List)

#iptables -L

 

 

INPUT (서버로 들어오는 것 관리), FORWARD (서버에서 내부망으로 연결관리;잘 안씀), OUTPUT (서버에서 나가는 것 관리)
로 이루어져 있다.

보통 FORWARD와 OUTPUT은 건들이지 않고 INPUT 만 수정한다.
policy ACCEPT 라는 뜻은 아무 조건도 해당하지 않았을 때 ACCEPT 하라는 것이다.

먼저 현재 방화벽 설정을 파일로 저장한다. 언제든 현재의 상태로 되돌릴 수 있기 위해서 이다.

#cd ~
#mkdir firewall_rules
#cd firewall_rules
#iptables-save > 151214.rules                 현재 날짜 쓰세요.

이제 방화벽을 복구해 보자.

#iptables-restore < 151214.rules
#iptables -L

>>설정 시작.
규칙 : 아이피 111.222.111.222 에 대해서 destination port 가 22 이면 ACCEPT 하여라.

#iptables -A INPUT -s 111.222.111.222/32 -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

아이피 바꾸지 마시고 위의 예시 (111.222.111.222) 그대로 입력하세요.

#iptables -L

 

 

 

이제 현재 상태에 대해서 방화벽 설정파일을 다시 생성해보도록 하자.

#iptables-save > 151214.rules

 

SFTP나 vi, cat 으로 해당 151214.rules 를 열어보자.

열고나서 코드의 뜻을 대충 해석해보아라. (간단하다.)

하단 *filter 부분에

-A INPUT -s 111.222.111.222/32 -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

가 보이는가?

 

여러분은 이곳에 아래의 코드를 집어넣어야 한다.

순서가 중요하다. IF-ELSE 같이 동작하기 때문에 조건에 맞으면 바로 지정된 동작을 한다.

211.105.192.168 아이피만 지정하고 싶을 때 -> -s 211.105.192.168/32

211.105.192.* 아이피 그룹을 지정하고 싶을 때 -> -s 211.105.192.0/24

211.105.*.* 아이피 그룹을 지정하고 싶을 때 -> -s 211.105.0.0/16

목적지 포트가 22번(ssh) 포트일 때 -> -dport 22

목적지 포트가 80번(http) 포트일 때 -> -dport 80

목적지 포트가 443번(https) 포트일 때 -> -dport 443

 

아래는

1. 이미 연결된 것은 허용
2. ping 허용
3. loopback 허용
4. 111.222.111.222 의 22번 포트 접근 허용
5. 123.111.123.111 의 22번 포트 접근 허용
6. 80 포트 접근 허용 (-s 옵션이 없으므로 누구나 허용)
7. 443 포트 접근 허용 (-s 옵션이 없으므로 누구나 허용)
8. 차단
9. FORWARD 차단

의 코드이다.

아까 생성한 .rules 파일을 열어서 아래의 코드를 그림과 같이 코드를 추가하여라. 이때 반드시 당신의 아이피를 추가하여라.

추가가 잘못되어도 어차피 1번의 조건에 의해서 당신의 연결이 끊기지는 않겠지만 새로운 연결은 차단될 것이다.

 

 

 

1

2

3

4

5

6

7

8

9

 

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -s 111.222.111.222/32 -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

-A INPUT -s 123.111.123.111/32 -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT

-A INPUT -j REJECT --reject-with icmp-host-prohibited

-A FORWARD -j REJECT --reject-with icmp-host-prohibited

 

 

 

 

 

#iptables-restore < 151214.rules
#iptables -L

!!!반드시 현재 쉘 연결을 끊지 말고!!!

현재 연결은 1번 조건에 의해서 반드시 허용이기 때문에 괜찮다.

 

새로 연결창 띄워서 테스트해 보아라.

만약 원하는대로 동작하지 않는다면 다시 .rules 파일을 수정하고 iptables-restore 하여라.

방화벽 설정이 머리가 아프다면

# iptables -F

 초기화 하고 내일 다시 시도해 보아라.

 

이 설정은 재부팅이 되면 초기화 된다.

설정을 지속시키도록 하자.

iptables-persistent 설치

 

 

#apt-get install iptables-persistent

Yes (엔터), Yes (엔터)

 

/etc/iptables 라는 폴더가 생성되고

rules.v4, rules.v6 가 생성된다.

 

부팅시 실행되는 파일을 갱신하자.

#iptables-save > /etc/iptables/rules.v4

 

ipv6 차단하기

#vi /etc/sysctl.conf

맨 밑에

 

 

1

2

3

 

net.ipv6.conf.all.disable_ipv6 = 1

net.ipv6.conf.default.disable_ipv6 = 1

net.ipv6.conf.lo.disable_ipv6 = 1

 

 

 

추가.

 

설정파일 적용

#sysctl -p

 

검사

#cat /proc/sys/net/ipv6/conf/all/disable_ipv6

1 이면 disable 된 상태이다.

 

 

 

재부팅

#reboot

 

 

재부팅 후에 방화벽 규칙이 유지가 되면 성공이다.

#iptables -L




 

옵션) 계정별 트래픽 양 제한하기. Apache Mod Cband install.

- 2015.06.01. Ubuntu 14.04 LTS 테스트 완료. 
- 순간속도(대역폭), 총 전송량(쿼터), 동시접속연결을 제한하는 모듈입니다.
장애가 일어날 것 같은 값들을 Hard Boundary 로 정해놓으면 장애가 일어날 것 같은 환경에서 서버가 잘 돌아가는 것을 볼 수 있을 것입니다.

저도 서버 서비스의 장애를 막기 위해서 실 서비스에 이것을 사용하고 있습니다.
다만 저 같은 경우 분산처리를 해 두었기 때문에 개별 서버에 적용한 제한치보다 실제 서비스는 더 높은 처리를 보여줍니다. (100의 제한을 건 서버 5대에 분산처리하면 전체적으로 500의 제한이 걸린 것 처럼 보이겠죠?)

 

Mod Cband  Apache2 모듈입니다.

다음의 기능이 가능합니다.

1) 대역폭 제한 (Bandwidth limit)
2) 동시 접속자 제한 (Concurrent user)
3) 트래픽 제한 (Transfer quota)
통계 용도로만 사용할 수도 있다.

 

현재 공식사이트가 닫혀있어서 대체할 만한 다운로드 경로를 적는다.

1) mod cband 공식사이트 : http://cband.linux.pl/  (안열림.)
2) mod cband 메인 개발자 블로그 : http://dembol.org/blog/mod_cband/ (다운로드 링크가 동작안함)
3) source forge 링크 : http://sourceforge.net/projects/cband/files/ (최신버전이 아님)

4) 현존하는 것 중에서 가장 최선의 선택 https://fossies.org/linux/www/apache_httpd_modules/mod-cband-0.9.7.5.tgz/

5) 라엘이 블로그 백업용 파일 (4번과 완전히 동일한 파일) mod-cband-0.9.7.5.zip

 

1] mod cband 는 apxs 라는 아파치 확장 개발 라이브러리를 필요로 합니다.
#apt-get install apache2-dev

 

2] apache cband module 다운로드
#wget https://fossies.org/linux/www/apache_httpd_modules/mod-cband-0.9.7.5.tgz

 

 

3] 압축을 풀고 설치
#tar -xzvf mod-cband-0.9.7.5.tgz#cd mod-cband-0.9.7.5

 

3-1] 패치.

apxs 가 업데이트 되면서 변수명이 몇개 바뀌었다.

#vi src/mod_cband.c

찾기 : remote_addr      ,    바꾸기 : client_addr       1365번째줄1회만 치환되어야 함.

 

찾기 : remote_ip       ,    바꾸기 : client_ip     4회 치환되어야 함.

 

 

3-2]  설치 계속 진행.#./configure#make#make install

 

 

4] cband 모니터링 페이지 생성
#vi /etc/apache2/mods-available/cband.conf

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

<IfModule mod_cband.c>

    <Location /cband-status>

        SetHandler cband-status

        AuthName "adminpage"

        AuthType Basic

        AuthUserFile /home/.htpasswd

        require valid-user

    </Location>

    <Location /cband-status-me>

        SetHandler cband-status-me

        Order deny,allow

        Deny from all

        Allow from all

    </Location>

</IfModule>

 

#htpasswd -c -m /home/.htpasswd admin

 

5] 아파치 모듈 켜기
#a2enmod cband

 

6] 적용을 위해서 아파치 재시작
#service apache2 restart

 

7] 확인

웹브라우져로

서버아이피/cband-status-me

서버아이피/cband-status

에 들어가 보자.

지금은 모두 무제한이므로 아무 항목이 뜨지 않을 것이다.

 

8] 설정하기.

https://www.linux.co.kr/home/lecture/?leccode=10588

위의 링크 글을 참조하여 이미 생성해서 사용중인 sites-available 안의 virtualhost 파일을 수정한다.

 

9] 설정 예제.

각 사이트의 <virtualhost> 구문에 Cband 설정 값을 추가한다. 다 쓸 필요는 없다. 필요한 제한만 두도록 하자.

 

당신이 웹호스팅을 운영중이라면 CBandLimit 구문과 CBandPeriod 구문을 사용하여라.

 

당신이 동영상 사이트나, 자료실을 운영중이라면 CBandSpeed 와 CbandExceededSpeed 를 사용하여라.

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

<VirtualHost *:80>

    #main domain

    ServerName lael.be

    #something

    #~~~

    #~~~

     

    <IfModule mod_cband.c>

        #4주동안 6GB 전송량 제한을 둠. 초과시 503 Service 에러페이지가 뜸.

        CBandLimit 6G

        CBandPeriod 4W

        #트래픽 조각. 이 상황의 경우 1주일마다 1.5GB 가 보급된다.

        #트래픽이 CbandPeriod 기간동안 골고루 사용되기를 원할때 설정한다.

        CBandPeriodSlice 1W

         

        #동영상(flv, mp4)이나 자료실 서비스를 하고 싶을때에만 아래의 속도제한 구문작성

        CBandSpeed 500kbps 10 30

        CBandExceededSpeed 128kbps 5 15

        #CBandScoreboard /var/www/scoreboard/domain.com.scoreboard

    </IfModule>

 

</VirtualHost>

 


 

옵션 ) 서버 동시접속자 설정 변경하기. (15.11.20 추가)

다음의 페이지를 많이 참조했습니다. (http://www.zarafa.com/wiki/index.php/Apache_tuning)

문의주시는 분들 중에 간혹 의도치않은 대박(?)이 일어나신 분들이 있더라. 동시접속 튜닝법을 설명하고자 한다.

 

몇가지 배경지식 설명.

- http 웹페이지는 stateless(connectionless) 입니다. 즉 페이지 불러올 때에만 서버와 연결하고 페이지 로드가 끝난 후에는 연결을 끊습니다.

- 1개의 연결당 평균 메모리 소모량은 20MB 입니다. (라엘이가 관리하는 여러서버의 평균값을 내보았음)

- Ubuntu Apache 의 기본 동시접속자 제한은 150개 입니다. 1000개의 동시접속이 연결되면 150개는 즉시 처리진행되고, 나머지 850개는 대기열에서 대기하다가 차례대로 처리됩니다.

1] 서버 연결당 얼마나 메모리를 소모하는지 확인ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}'

2] 서버에 여유 메모리 자원이 얼마나 있는지 확인

서버를 재부팅한 후에 아파치를 종료후 서버의 메모리를 확인해본다.

# free -m

 

3] 하드웨어 자원을 고려한 가용 동시연결수 계산

여유 메모리 / 1연결당 메모리     하면 된다.

2000MB free memory 가 있고, 1연결당 20MB 를 사용한다면 = 100개의 동시연결 가능. (300~500 동시접속자 처리가능)

 

4] 사이트의 필요 동시연결수 계산

450명의 사용자가 있고 3초주기로 페이지 이동이 일어난다고 가정하자. 페이지 출력 실행시간은 2초라고 가정하자.

필요 동시연결수 = 450 / 3 * 2 = 300

 

5] 동시연결수 설정 변경.# vi /etc/apache2/mods-available/mpm_prefork.conf

MaxRequestWorkers 값을 수정해야 합니다.

ServerLimit 라는 옵션의 기본값이 256이기 때문에 MaxRequestWorkers 값이 256보다 작으면 따로 적을 필요가 없으며, 256보다 크면 그와 같은 값으로 ServerLimit 도 설정해야 합니다.

동시연결 제한 300 예제 설정법.

1

2

3

4

5

6

7

8

<IfModule mpm_prefork_module>

    StartServers 5

    MinSpareServers 5

    MaxSpareServers 10

    MaxRequestWorkers 300

    ServerLimit 300

    MaxConnectionsPerChild 0

</IfModule>

 

출처: blog.lael.be/post/73

'Linux > Ubuntu' 카테고리의 다른 글

Ubuntu VNC 설치  (0) 2021.03.20
Ubuntu Network & WOL  (0) 2021.03.17
Ubuntu 20.04 LTS Server 버전 설치  (0) 2021.03.16
Posted by iWithJoy
Linux/Ubuntu2021. 3. 20. 23:59

$ sudo apt install tasksel -y
$ sudo tasksel

VNC is a system that allows you to remotely control another computer. It allows you to relay your mouse and keyboard inputs as if you were physically sitting in front of the system, when in fact you could be on the other side of the world.

In this guide, we will go over the steps to setup a VNC server on your Ubuntu 20.04 system. When we're done, you'll be able to access your system remotely from anywhere, provided that your client system and the VNC server have an internet connection.

In this tutorial you will learn:

  • How to install and configure TightVNC Server
  • How to install and configure XFCE desktop manager
  • How to connect to our VNC server with TightVNC Viewer
  • How to tunnel VNC connections through SSH
  • How to manage multiple VNC desktops with a Systemd script

Connecting to a VNC server

Software Requirements and Linux Command Line ConventionsCategoryRequirements, Conventions or Software Version Used

System Installed or upgraded Ubuntu 20.04 Focal Fossa
Software TightVNC Server, XFCE desktop manager, TightVNC Viewer
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

Install VNC server


Looking for Linux Systems Analyst !

The UAF Geophysical Institute, is looking for an experienced Linux Systems Analyst to join their team of research cyber infrastructure analysts and engineers. LOCATION: Fairbanks, Alaska, USA

APPLY NOW



We'll need to install a few packages first. There are multiple options for VNC server software, but we'll be going with TightVNC Server for this tutorial. Along with VNC, we also need a graphical desktop. XFCE is a good choice, so that's what we'll be covering here.

    1. Start by opening a terminal and entering the following command to install TightVNC server and the XFCE desktop manager core files:
      $ sudo apt install tightvncserver xfce4 xfce4-goodies
    2. After the packages are done installing, we need to configure a username and password that will be used to connect to the VNC server by a client. Create a password with this command:$ vncpasswd
    3. Next, let's configure VNC to start the XFCE desktop environment when a client connects. Use nano or the text editor of your preference (ex. Atom, Sublime) to create the following file:
      $ nano ~/.vnc/xstartup

 


$ systemctl set-default graphical.target


  1. Insert the following few lines and then save your changes and exit the file:

    #!/bin/sh
    unset SESSION_MANAGER
    unset DBUS_SESSION_BUS_ADDRESS
    startxfce4 &
    xstartup configuration file
  2. With those changes made, edit the permissions of the file to make it executable:$ chmod +x ~/.vnc/xstartup

Start VNC server



VNC runs as a service on your system. In order for clients to connect, the VNC server must obviously be running and listening for incoming connection attempts. With our configuration complete, we are ready to start VNC server with the following command:

$ vncserver

If your terminal returns some output like in the screenshot below, your VNC server is running correctly.

Launch VNC server

VNC will use a new port for every remote desktop that is created. At this point, your system should be listening on port 5901 for incoming VNC connections. You can see this for yourself with the ss -ltn command:

$ ss -ltn

VNC listening on port 5901

If you have the UFW firewall enabled, you'll need to open port 5901 so it doesn't block incoming VNC connections:

$ sudo ufw allow from any to any port 5901 proto tcp Rule added Rule added (v6)


Looking for Linux Systems Analyst !

The UAF Geophysical Institute, is looking for an experienced Linux Systems Analyst to join their team of research cyber infrastructure analysts and engineers. LOCATION: Fairbanks, Alaska, USA

APPLY NOW



Connect to VNC server

There are a lot of choices in the way of VNC clients and any of them should be capable of connecting to your newly launched VNC server. If you don't already have a preferred client to use, follow along with us as we cover the instructions for connecting to the VNC server with the TightVNC Viewer.

    1. Start by installing the xtightvncviewer package on your Ubuntu client system:$ sudo apt install xtightvncviewer
    2. Once the VNC client is installed, you can use the vncviewer command, followed by either the hostname or IP address of the VNC server, in order to connect to it.$ vncviewer linuxconfig.org:1 Enter your password that we created previously when setting up VNC Server. If all went well, you will be presented with a XFCE desktop session running on the remote VNC server Ubuntu system:
      Connect to VNC server


Tunnel VNC through SSH

For extra security, you can tunnel the VNC connection through SSH on your VNC server. Of course, this is assuming that you have SSH access on the VNC server. If you'd like the added security, follow along with these steps:

    1. If you don't already have SSH installed, that's a pretty obvious prerequisite for this to work:$ sudo apt install ssh
    2. Next, create an SSH tunnel on a local port 5901 leading to a remote port 5901 on your VNC server. In the following command, make sure you replace user1 and linuxconfig with the username and hostname of your VNC server:$ ssh -L 5901:127.0.0.1:5901 -N -f -l user1 linuxconfig The above command will open a local port 5901 on a localhost loopback network interface 127.0.0.1:

      $ ss -ltn

      State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 5 127.0.0.1:631 0.0.0.0:* LISTEN 0 128 127.0.0.1:6010 0.0.0.0:* LISTEN 0 128 127.0.0.1:6011 0.0.0.0:* LISTEN 0 128 0.0.0.0:38299 0.0.0.0:* LISTEN 0 128 127.0.0.1:5901 0.0.0.0:*


  1. Next, use the local port 5901 to connect to a remote VNC server via the SSH tunnel:$ vncviewer localhost:1

VNC server system startup script

While this configuration works, you may have a scenario where you need to manage multiple VNC desktop sessions. In that case, creating a systemd startup script can facilitate that.

Use nano or another text editor to create the following file:

$ sudo nano /etc/systemd/system/vncserver@.service

Once you have the file opened, insert the following lines while replacing the user1 username with the username of your VNC user on Line 7 and Line 10. Optionally, change the screen resolution settings and apply other vncserver options or arguments:

[Unit]
Description=Systemd VNC server startup script for Ubuntu 20.04

After=syslog.target network.target

[Service]
Type=forking

User=user1
ExecStartPre=-/usr/bin/vncserver -kill :%i &> /dev/null
ExecStart=/usr/bin/vncserver -localhost no -depth 24 -geometry 1280x1024 :%i

PIDFile=/home/user1/.vnc/%H:%i.pid
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

 


Looking for Linux Systems Analyst !

The UAF Geophysical Institute, is looking for an experienced Linux Systems Analyst to join their team of research cyber infrastructure analysts and engineers. LOCATION: Fairbanks, Alaska, USA

APPLY NOW



Systemd startup file

Next, reload Systemd for the changes to take effect:

$ sudo systemctl daemon-reload

To start VNC desktop 1, enter:

$ sudo service vncserver@1 start

To stop VNC desktop 1, execute:

$ sudo service vncserver@1 stop

The following linux command will enable the VNC desktop 1 to start after reboot:

$ sudo systemctl enable vncserver@1

$ sudo systemctl start vncserver@1
$ sudo systemctl status vncserver@1
$ vncserver -localhost no

To start VNC desktop 2, enter:

$ sudo service vncserver@2 start

 

출처: linuxconfig.org/vnc-server-on-ubuntu-20-04-focal-fossa-linux

 

 

1. 우분투 데스크탑 설치하기

우선 다음 명령어를 입력하여 우분투를 업데이트해줍니다.

sudo apt update && sudo apt upgrade

다음 명령어를 입력하여 우분투 데스크탑을 설치해줍니다.

sudo apt-get install ubuntu-desktop

시간이 좀 오래 걸리니 기다려주세요.

 

2. VNC 설치하기

VNC를 통해 원격접속하기 위해서는 원격 접속을 당할 시스템과 원격 접속을 할 시스템 양쪽 모두에 VNC 프로그램이 설치되어있어야 합니다.

WSL2의 우분투는 원격 접속을 당할 시스템이므로 VNC서버를 설치해주겠습니다.

 

다음 명령어를 입력해 VNC서버를 설치해줍니다.

sudo apt-get install tigervnc-standalone-server

이번엔 dotnet-runtime을 설치해줍니다.

sudo wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt install dotnet-runtime-3.1

이번엔 systemd-genie를 설치해줍니다.

아래 명령어를 입력하여 파일을 하나 만들어주세요.

sudo nano /etc/apt/sources.list.d/wsl-translinux.list

만들어진 파일에 다음과 같은 내용을 붙여넣어줍니다.

deb [trusted=yes] https://wsl-translinux.arkane-systems.net/apt/ /

이제 다음 명령어를 입력하여 설치를 마무리합니다.

sudo apt update
sudo apt install systemd-genie

 

 

3. VNC 환경설정

다음 명령어를 입력하여 비밀번호를 설정해줍니다.

선택 옵션에서는 n을 입력하여주세요.

vncpasswd

다음 명령어를 입력하여 한번 더 반복해주세요.

sudo vncpasswd

마지막입니다.

한번 더 반복해주세요.

sudo -u gdm vncpasswd

이제 기존의 X를 Xvnc로 대체해주겠습니다.

다음 명령어를 입력하여 Xorg스크립트를 백업해주세요.

sudo mv /usr/bin/Xorg /usr/bin/Xorg_old

이제 다음 명령어를 입력하여 새로운 Xorg 스크립트를 만들어줍니다.

sudo nano /usr/bin/Xorg

만들어진 스크립트에 다음 내용을 붙여넣기 해줍니다.

#!/bin/bash
for arg do
  shift
  case $arg in
    # Xvnc doesn't support vtxx argument. So we convert to ttyxx instead
    vt*)
      set -- "$@" "${arg//vt/tty}"
      ;;
    # -keeptty is not supported at all by Xvnc
    -keeptty)
      ;;
    # -novtswitch is not supported at all by Xvnc
    -novtswitch)
      ;;
    # other arguments are kept intact
    *)
      set -- "$@" "$arg"
      ;;
  esac
done

# Here you can change or add options to fit your needs
command=("/usr/bin/Xvnc" "-geometry" "1024x768" "-PasswordFile" "${HOME:-/root}/.vnc/passwd" "$@") 

systemd-cat -t /usr/bin/Xorg echo "Starting Xvnc:" "${command[@]}"

exec "${command[@]}"

이제 다음 명령어로 파일에 대한 권한을 설정해줍니다.

sudo chmod 0755 /usr/bin/Xorg

다음 명령어를 입력하여 재부팅시켜주세요

genie -s

이제 준비가 끝났습니다.

 

4. IP 확인하기

다음 명령어를 입력하여 net-tools를 설치해주세요.

sudo apt install net-tools

다음 명령어로 IP를 확인해줍니다.

ifconfig

제가 빨갛게 칠한 부분이 여러분의 IP입니다.

출처: bebutae.tistory.com/145?category=943715

'Linux > Ubuntu' 카테고리의 다른 글

Ubuntu 웹서버 구축  (0) 2021.03.21
Ubuntu Network & WOL  (0) 2021.03.17
Ubuntu 20.04 LTS Server 버전 설치  (0) 2021.03.16
Posted by iWithJoy
Linux/Ubuntu2021. 3. 17. 23:24

우분투 Netplan

우분투 18.04 설치하고 사용하고 계신 분들은 아시겠지만, 이전 LTS 버전과 가장 큰 차이점 중에서 하나가 바로 네트워크 설정 방법 변경된 것일 겁니다.
사실 Netplan은 우분투 18.04 이전 버전인 17.10 버전부터 네트워크 설정을 관리하기 위해서 사용되었습니다. Netplan은 기존의 우분투 네트워크 인터페이스를 관리하기 위해서 사용되는 파일들(/etc/network/interfaces)을 대체하기 위한 툴입니다. 우분투 18.04 LTS 버전 부터는 기존의 설정 파일이 아닌, /etc/netplan/*.yaml 를 사용해 주셔야합니다.

새로운 인터페이스 설정파일들은 /etc/netplan 디렉터리에 존재하며, 크게 NetworkManager 와 networkd 으로 renderer 값을 갖습니다.

  • NetworkManager : 데스크탑 컴퓨터에서 사용됩니다. 이 값이 renderer로 사용되었을 경우 NetworkManager GUI를 통해서 네트워크 인터페이스가 관리되게 됩니다. 직접 Netplan 설정 파일을 통해 네트워크 설정을 하는것이 아니고 NetworkManager의 GUI를 통해서 설정되게 됩니다.
  • networkd : 주로 서버에서 사용되는 renderer입니다. 이 글에서는 networkd의 renderer 값으로 설정 방법을 설명드리도록 하겠습니다.

Netplan 설정 파일 구조

설정 파일의 최상위 노드 정보는 network 입니다. network는 “version: 2” (Curtin에서 사용되는 YAML), 그리고 renderer 등이 정의 됩니다. 그리고 renderer 값에 따라 “ethernets:”, “wifis:”, “bridges:” 와 같은 디바이스 정의 그룹이 추가 정의되게 됩니다. 각각의 디바이스 블럭은 map 형태로 세부적인 형태로 정의가 이뤄지게 됩니다. 보다 자세한 내용은 아래의 설정 파일을 통해서 설명드리도록 하겠습니다.

우분투 18.04 네트워크 설정

설정 파일
만약 우분투 18.04 데스크탑 버전을 설치하신 경우, /etc/netplan 디렉터리의 설정파일을 확인하시면 아래와 같은 내용이 있습니다.

# Let NetworkManager manage all devices on this system network: version: 2 renderer: NetworkManager

NetworkManager을 renderer으로 사용한다는 내용으로, NetworkManager의 GUI를 이용하여 네트워크 설정이 이뤄지게 됩니다.

이더넷 DHCP 설정

아래의 설정 내용은 이더넷 enp6s0 인터페이스를 DHCP 방식으로 설정하는 내용입니다.

network: 
  version: 2 
  renderer: networkd
  ethernets: enp3s0: 
  dhcp4: yes 
  dhcp6: yes

설정 내용을 작성 후, 아래의 명령어를 실행하면 설정 내용이 적용되게 됩니다.

$ sudo netplan apply

이더넷 고정 IP 설정
아래의 설정 내용은 이더넷 enp6s0 인터페이스를 고정 IP 방식으로 설정하는 내용입니다.

network: 
  version: 2 
  renderer: networkd 
  ethernets: 
    enp3s0: 
      addresses: 
      - 192.168.11.111/24 
      gateway4: 192.168.11.1 
      nameservers: 
#        addresses: [168.126.63.1,8.8.8.8]
        addresses
: 
        - 8.8.8.8
        search:
        - 8.8.4.4

위의 내용으로 설정 후에 다음 명령어를 실행하면, 네트워크 설정이 적용되게 됩니다.

$ sudo netplan apply

 

무선랜 설정

무선랜 인터페스 wlp2s0 에 무선랜을 설정하는 예제 내용입니다.

network: 
  version: 2 
  renderer: networkd 
  wifis: 
    wlp2s0: 
      dhcp4: yes 
      access-points: 
        "network_ssid_name": 
          password: "**********"

주소는 DHCP 방식으로 할당받는 예제이며, AP(Access Point) 정보를 SSID 정보와 패스워드를 위와 같이 입력하면 됩니다.
그리고 아래의 명령어를 실행하면 설정이 적용되게 됩니다.

$ sudo netplan apply

출처: hiseon.me/linux/ubuntu/ubuntu-18-04-netplan/

 

리눅스 WiFi 연결 명령어

Network Manager 정지

우분투 리눅스 등의 데스크탑 환경에서는 Network Manager 데몬이 네트워크를 관리하는데 사용됩니다. Network Manager가 실행중일 경우 이 데몬을 아래의 명령어로 먼저 정지해 주시기 바랍니다.

$ sudo /etc/init.d/network-manager stop

최신 우분투 버전에서 사용되는 netplan 과 관련해서는 아래의 글을 참고해 주시기 바랍니다.

우분투 18.04 네트워크 설정

리눅스 WiFi 연결 명령어

무선랜 인터페이스 확인

다음의 명령어로 인터페이스 이름을 확인합니다.

$ iw dev

명령어 실행 결과, 무선랜 카드 인터페이스 이름은 wlxe84e06710cec 으로 확인되고 있습니다. 앞으로 이 인터페이스 이름을 이용하여 설정에 사용되게 됩니다.

무선랜 인터페이스 활성화

그리고 아래의 명령어로 인터페이스를 확인 합니다.

$ sudo ip link show wlxe84e06710cec

현재 무선랜 카드가 활성화 되어있지 않으므로, 다음 명령어를 사용하여 무선랜 카드를 활성화 합니다.

$ sudo ip link set wlxe84e06710cec up

그리고 다시 무선랜 카드 정보를 확인합니다. 처음과 다르게 활성화 된 무선랜 카드 정보를 확인 할 수 있습니다.

$ sudo ip link show wlxe84e06710cec

연결 상태 확인

다음 명령어를 사용하여, 현재 무선랜 카드의 연결 상태를 확인 합니다.

$ iw wlxe84e06710cec link

현재 WiFi에 연결되어 있지 않은 걸 알 수 있습니다.

WiF 스캔

다음 명령어를 사용하여 WiFi 정보를 스캔합니다. 스캔 후 나타나는 WiFi 중에서 비밀번호가 없는 WiFi 와 WPA/WPA2 암호화 방식을 사용하는 WiFi에 대해서 나눠서 설명드리도록 하겠습니다.

공개된 WiFi 일 경우

공개된 WiFi 일 경우 아래와 같은 명령어를 사용하여, SSID를 확인 한 다음 바로 WiFi에 연결 할 수 있습니다.

아래의 명령어는 iptime 이라는 WiFi에 접속하는 명령어 입니다. 그 다음 연결접속 정보를 확인 후 IP를 할당 받으면 됩니다.

$ iw wlxe84e06710cec scan $ sudo iw dev wlxe84e06710cec connect iptime

비공개된 WiFi 일 경우 (WPA/WPA2)

WPA/WPA2 암호화 방식을 사용하는 WiFi 정보입니다. 네트워크를 스캔하면 다음과 비슷한 결과가 나타납니다.

$ iw wlxe84e06710cec scan // 생략 BSS 34:cc:28:05:f0:58(on wlxe84e06710cec) TSF: 175628935496 usec (2d, 00:47:08) freq: 2432 beacon interval: 100 TUs capability: ESS Privacy ShortSlotTime (0x0411) signal: -69.00 dBm last seen: 800 ms ago Information elements from Probe Response frame: SSID: ktEgg_F058 WPA: * Version: 1 * Group cipher: TKIP * Pairwise ciphers: TKIP CCMP * Authentication suites: PSK RSN: * Version: 1 * Group cipher: TKIP * Pairwise ciphers: TKIP CCMP * Authentication suites: PSK * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000) // 생략

위의 스캔된 정보에서 가장 중요한 내용이 SSID 와 암호화 프로토콜입니다. RSN 방식이 WPA2 를 나타냅니다. WiFi의 SSID 이름이 ktEgg_F058 일 경우 설정 후 접속하는 방법입니다.

아래의 명령어를 실행 후, WiFi 패스워드를 입력하면 설정 파일이 생성되게 됩니다.

$ sudo wpa_passphrase ktEgg_F058 > wpa_supplicant.conf

이 설정 파일을 이용하여 다음 명령어를 이용하여 WiFi 에 접속하면 됩니다.

$ sudo wpa_supplicant -B -i wlxe84e06710cec -c wpa_supplicant.conf

위의 명령어에서 사용된 옵션의 의미는 다음과 같습니다.

  • -B : 백그리운드 실행
  • -i wlxe84e06710cec : 무선랜 인터페이스 이름
  • -c wpa_supplicant.conf : WiFi 설정 파일 경로

WiFi 연결 정보 확인

WiFi 에 접속 후 연결 정보를 확인 합니다.

$ sudo iw wlxe84e06710cec link

명령어 실행 결과 SSID 가 출력되며, 연결 정보가 나타나는 것을 확인 할 수 있습니다.

DHCP 주소 할당

성공적으로 WiFi에 접속되게 되면, 아래의 명령어로 IP 주소를 할당 받습니다.

$ sudo dhclient wlxe84e06710cec

위의 명령어 실행 결과, 에러 없이 IP 주소가 할당되었을 경우 WiFi 연결이 성공적으로 이뤄진 것입니다.

출처: hiseon.me/network/linux-wifi-command-line/

 

VNC를 이용한 우분투 원격접속하기

서버로 사용하기 위해서느 원격 접속이 필수인데, 지난 번 포스팅처럼 xrdp를 이용하면 Windows에서는 접속이 가능하지만 스마트폰 같은 다른 운영체제에서는 프로토콜 에러라는 메세지와 함께 접속이 안되는 문제가 있다. 그래서 rdp가 아닌 vnc를 이용한 원격접속 방법을 시도했다. rdp를 이용하면 로컬에서는 접속이 끊기고 원격지에서만 PC를 제어하지만 VNC는 로컬 시스템에 사용자가 로그인되어 있어야하고, 같은 화면을 보면서 PC를 제어하게 된다. 스마트폰 초창기에 유행한 크레이지 리모트나, 팀뷰어를 생각하면 된다.


우분투 최신 LTS 버전인 18.04 기준

 Windows에서 원격 데스크톱 허용하듯이 이렇게만 설정해주면 리눅스끼리의 원격 접속은 문제없지만, 다른 운영체제에서 접속하는데는 암호화 관련 문제가 있다. 그래서 관련 설정을 꺼주어야 한다. 아래 명령어로 dconf 에디터를 설치해준다.

apt install dconf-editor

 

dconf-editor 실행 후 /org/gnome/desktop/remote-access 항목으로 들어가서 require-encryption 옵션을 꺼준다.

   

Play 스토어에서 VNC로 검색을 하고 제일 위에 있는 앱을 설치해봤다. VNC는 기본포트로 5900을 사용하는데, 암호화 기능도 끈 상태이기 때문에 다른 포트로 바꿔서 사용하는게 좋을 것 같다.

출처: https://junhyeok.tistory.com/690 [Half Time]

 

우분투 WOL 설정하기

그 동안 우분투에서도 잘 써왔다고 생각했던 WOL(Wake On Lan) 기능이 얼마전부터 잘 작동되지 않는다. 그래서 이번에도 검색을 해보니 메인보드 바이오스의 설정 외에도 운영체제에서 랜카드 설정이 필요하다고 한다. Windows나 우분투 16.04 PC를 사용할 때는 별도 설정이 없어도 대부분 잘되었기 때문에 신경쓰지 않던 부분인데 아마 우분투 18.04를 새로 설치하면서부터 뭔가 변경되었나보다.

1.ethtool 설치 : ethtool이라는 명령어를 통해서 PC가 꺼졌을때 랜카드가 대기하도록 해야한다.
sudo apt install ethtool 를 입력해서 ethtool을 먼저 설치한다.

2. ifconfig를 통해서 랜카드 정보를 확인한다. enp6s0라고 쓰여있는 부분을 기억해둔다.
사용자에 따라 약간씩 다를 수 있다.
sudo apt install net-tools 를 입력해서 설치 후에 ifconfig 사용이 가능하다.

 ethtool 명령으로 랜카드의 상태를 확인해본다. Wake-on: g 라고 되어있으면 wol 기능이 활성화된 것이다. d는 비활성화(disabled)를 의미한다. 스크린샷은 활성화 상태로 만든 후에 찍은 것이라 g로 나와있다.

sudo nano /etc/rc.local

나노 에디터를 이용해서 /etc 디렉토리에 rc.local 이라는 파일을 만들고 아래 내용을 입력한다. rc.local은 Windows의 시작프로그램과 같은 역할이라고 보면 된다.

#!/bin/bash
ethtool -s enp6s0 wol g
exit 0

나노 에디터는 Ctrl + O로 저장, Ctrl + X로 종료해준다.

sudo chmod +x /etc/rc.local 

좀전에 만든 rc.local 파일을 chmod +x 명령어로 실행파일로 만들어준다. 

sudo /etc/rc.local
실행 후,

sudo ethtool enp6s0
명령으로 Wake-on: g 로 되어 있는지 확인한다.

출처: https://junhyeok.tistory.com/704 [Half Time]

 

우분투 VNC server 설치

How To Install VNC Server on Ubuntu 20.04

 

Introduction

Virtual Network Computing, or VNC, is a connection system that allows you to use your keyboard and mouse to interact with a graphical desktop environment on a remote server. It makes managing files, software, and settings on a remote server easier for users who are not yet comfortable with the command line.

In this guide, you’ll set up a VNC server with TightVNC on an Ubuntu 20.04 server and connect to it securely through an SSH tunnel. Then, you’ll use a VNC client program on your local machine to interact with your server through a graphical desktop environment.

Prerequisites

To complete this tutorial, you’ll need:

  • One Ubuntu 20.04 server with a non-root administrative user and a firewall configured with UFW. To set this up, follow our initial server setup guide for Ubuntu 20.04.
  • A local computer with a VNC client installed. The VNC client you use must support connections over SSH tunnels:

Step 1 — Installing the Desktop Environment and VNC Server

By default, an Ubuntu 20.04 server does not come with a graphical desktop environment or a VNC server installed, so you’ll begin by installing those.

You have many options when it comes to which VNC server and desktop environment you choose. In this tutorial, you will install packages for the latest Xfce desktop environment and the TightVNC package available from the official Ubuntu repository. Both Xfce and TightVNC are known for being lightweight and fast, which will help ensure that the VNC connection will be smooth and stable even on slower internet connections.

After connecting to your server with SSH, update your list of packages:

  • sudo apt update

 

Now install Xfce along with the xfce4-goodies package, which contains a few enhancements for the desktop environment:

  • sudo apt install xfce4 xfce4-goodies

 

During installation, you may be prompted to choose a default display manager for Xfce. A display manager is a program that allows you to select and log in to a desktop environment through a graphical interface. You’ll only be using Xfce when you connect with a VNC client, and in these Xfce sessions you’ll already be logged in as your non-root Ubuntu user. So for the purposes of this tutorial, your choice of display manager isn’t pertinent. Select either one and press ENTER.

Once that installation completes, install the TightVNC server:

  • sudo apt install tightvncserver

 

Next, run the vncserver command to set a VNC access password, create the initial configuration files, and start a VNC server instance:

  • vncserver

 

You’ll be prompted to enter and verify a password to access your machine remotely:

Output

You will require a password to access your desktops. Password: Verify:

The password must be between six and eight characters long. Passwords more than 8 characters will be truncated automatically.

Once you verify the password, you’ll have the option to create a view-only password. Users who log in with the view-only password will not be able to control the VNC instance with their mouse or keyboard. This is a helpful option if you want to demonstrate something to other people using your VNC server, but this isn’t required.

The process then creates the necessary default configuration files and connection information for the server. Additionally, it launches a default server instance on port 5901. This port is called a display port, and is referred to by VNC as :1. VNC can launch multiple instances on other display ports, with :2 referring to port 5902, :3 referring to 5903, and so on:

Output

Would you like to enter a view-only password (y/n)? n xauth: file /home/sammy/.Xauthority does not exist New 'X' desktop is your_hostname:1 Creating default startup script /home/sammy/.vnc/xstartup Starting applications specified in /home/sammy/.vnc/xstartup Log file is /home/sammy/.vnc/your_hostname:1.log

Note that if you ever want to change your password or add a view-only password, you can do so with the vncpasswd command:

  • vncpasswd

 

At this point, the VNC server is installed and running. Now let’s configure it to launch Xfce and give us access to the server through a graphical interface.

Step 2 — Configuring the VNC Server

The VNC server needs to know which commands to execute when it starts up. Specifically, VNC needs to know which graphical desktop environment it should connect to.

The commands that the VNC server runs at startup are located in a configuration file called xstartup in the .vnc folder under your home directory. The startup script was created when you ran the vncserver command in the previous step, but you’ll create your own to launch the Xfce desktop.

Because you are going to be changing how the VNC server is configured, first stop the VNC server instance that is running on port 5901 with the following command:

  • vncserver -kill :1

 

The output will look like this, although you’ll see a different PID:

Output

Killing Xtightvnc process ID 17648

Before you modify the xstartup file, back up the original:

  • mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

 

Copy

Now create a new xstartup file and open it in a text editor, such as nano:

  • nano ~/.vnc/xstartup

 

Copy

Then add the following lines to the file:

~/.vnc/xstartup

#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 & 

Copy

The first line is a shebang. In executable plain-text files on *nix platforms, a shebang tells the system what interpreter to pass that file to for execution. In this case, you’re passing the file to the Bash interpreter. This will allow each successive line to be executed as commands, in order.

The first command in the file, xrdb $HOME/.Xresources, tells VNC’s GUI framework to read the server user’s .Xresources file. .Xresources is where a user can make changes to certain settings of the graphical desktop, like terminal colors, cursor themes, and font rendering. The second command tells the server to launch Xfce. Whenever you start or restart the VNC server, these commands will execute automatically.

Save and close the file after adding these lines. If you used nano, do so by pressing CTRL + X, Y, then ENTER.

To ensure that the VNC server will be able to use this new startup file properly, you’ll need to make it executable:

  • chmod +x ~/.vnc/xstartup

 

Copy

Then restart the VNC server:

  • vncserver -localhost

 

Copy

Notice that this time the command includes the -localhost option, which binds the VNC server to your server’s loopback interface. This will cause VNC to only allow connections that originate from the server on which it’s installed.

In the next step, you’ll establish an SSH tunnel between your local machine and your server, essentially tricking VNC into thinking that the connection from your local machine originated on your server. This strategy will add an extra layer of security around VNC, as the only users who will be able to access it are those that already have SSH access to your server.

You’ll see output similar to this:

Output

New 'X' desktop is your_hostname:1 Starting applications specified in /home/sammy/.vnc/xstartup Log file is /home/sammy/.vnc/your_hostname:1.log

With the configuration in place, you’re ready to connect to the VNC server from your local machine.

Step 3 — Connecting to the VNC Desktop Securely

VNC itself doesn’t use secure protocols when connecting. To securely connect to your server, you’ll establish an SSH tunnel and then tell your VNC client to connect using that tunnel rather than making a direct connection.

Create an SSH connection on your local computer that securely forwards to the localhost connection for VNC. You can do this via the terminal on Linux or macOS with the following ssh command:

  • ssh -L 59000:localhost:5901 -C -N -l sammy your_server_ip

 

Copy

Here’s what this ssh command’s options mean:

  • -L 59000:localhost:5901: The -L switch specifies that the given port on the local computer (59000) is to be forwarded to the given host and port on the destination server (localhost:5901, meaning port 5901 on the destination server, defined as your_server_ip). Note that the local port you specify is somewhat arbitrary; as long as the port isn’t already bound to another service, you can use it as the forwarding port for your tunnel.
  • -C: This flag enables compression which can help minimize resource consumption and speed things up.
  • -N: This option tells ssh that you don’t want to execute any remote commands. This setting is useful when you just want to forward ports.
  • -l sammy your_server_ip: The -l switch let’s you specify the user you want to log in as once you connect to the server. Make sure to replace sammy and your_server_ip with the name of your non-root user and your server’s IP address.

Note: This command establishes an SSH tunnel that forwards information from port 5901 on your VNC server to port 59000 on your local machine via port 22 on each machine, the default port for SSH. Assuming you followed the prerequisite Initial Server Setup guide for Ubuntu 20.04, you will have added a UFW rule to allow connections to your server over OpenSSH.

This is more secure than simply opening up your server’s firewall to allow connections to port 5901, as that would allow anyone to access your server over VNC. By connecting over an SSH tunnel, you’re limiting VNC access to machines that already have SSH access to the server.

If you are using PuTTY to connect to your server, you can create an SSH tunnel by right-clicking on the top bar of the terminal window, and then clicking the Change Settings… option:

Find the Connection branch in the tree menu on the left-hand side of the PuTTY Reconfiguration window. Expand the SSH branch and click on Tunnels. On the Options controlling SSH port forwarding screen, enter 59000 as the Source Port and localhost:5901 as the Destination, like this:

Then click the Add button, and then the Apply button to implement the tunnel.

Once the tunnel is running, use a VNC client to connect to localhost:59000. You’ll be prompted to authenticate using the password you set in Step 1.

Once you are connected, you’ll see the default Xfce desktop. It should look something like this:

You can access files in your home directory with the file manager or from the command line, as seen here:

Press CTRL+C in your local terminal to stop the SSH tunnel and return to your prompt. This will disconnect your VNC session as well.

Now you can configure your VNC server to run as a systemd service.

Step 4 — Running VNC as a System Service

By setting up the VNC server to run as a systemd service you can start, stop, and restart it as needed, like any other service. You can also use systemd’s management commands to ensure that VNC starts when your server boots up.

First, create a new unit file called /etc/systemd/system/vncserver@.service:

  • sudo nano /etc/systemd/system/vncserver@.service

 

The @ symbol at the end of the name will let us pass in an argument you can use in the service configuration. You’ll use this to specify the VNC display port you want to use when you manage the service.

Add the following lines to the file. Be sure to change the value of User, Group, WorkingDirectory, and the username in the value of PIDFILE to match your username:
/etc/systemd/system/vncserver@.service
-----------------------------------------------------------------------------------
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=forking
User=sammy
Group=sammy
WorkingDirectory=/home/sammy

PIDFile=/home/sammy/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 -localhost :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target
-----------------------------------------------------------------------------------

The ExecStartPre command stops VNC if it’s already running. The ExecStart command starts VNC and sets the color depth to 24-bit color with a resolution of 1280x800. You can modify these startup options as well to meet your needs. Also, note that the ExecStart command again includes the -localhost option.

Save and close the file.

Next, make the system aware of the new unit file:

  • sudo systemctl daemon-reload

 

Enable the unit file:

  • sudo systemctl enable vncserver@1.service

 

The 1 following the @ sign signifies which display number the service should appear over, in this case the default :1 as was discussed in Step 2.

Stop the current instance of the VNC server if it’s still running:

  • vncserver -kill :1

 

Then start it as you would start any other systemd service:

  • sudo systemctl start vncserver@1

 

You can verify that it started with this command:

  • sudo systemctl status vncserver@1

 

If it started correctly, the output should look like this:

Output

● vncserver@1.service - Start TightVNC server at startup Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2020-05-07 17:23:50 UTC; 6s ago Process: 39768 ExecStartPre=/usr/bin/vncserver -kill :1 > /dev/null 2>&1 (code=exited, status=2) Process: 39772 ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :1 (code=exited, status=0/SUCCESS) Main PID: 39795 (Xtightvnc) ...

Your VNC server is now ready to use whenever your server boots up, and you can manage it with systemctl commands like any other systemd service.

However, there won’t be any difference on the client side. To reconnect, start your SSH tunnel again:

  • ssh -L 59000:localhost:5901 -C -N -l sammy your_server_ip

 

Copy

Then make a new connection using your VNC client software to localhost:59000 to connect to your server.

Conclusion

You now have a secured VNC server up and running on your Ubuntu 20.04 server. Now you’ll be able to manage your files, software, and settings with a user-friendly graphical interface, and you’ll be able to run graphical software like web browsers remotely.

출처: tecadmin.net/install-vnc-server-on-ubuntu-20-04/www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-20-04

 

 

아래는 참고내용 ----------

vnc 리스트 보기

$ vncserver -list

 

vnc 지우기

특정 번호로 지우기

여기서 1은 5901 포트의 맨뒤 1

$ vncserver -kill :1

전체 지우기

$ vncserver -kill :*

 

connection refused

vnc viewer를 통해서 접속하려는데 connection refused 가 뜸...

netstat -tnlp를 통해서 확인 결과

::1:5901 식으로 이상하게 표시되어있음

 

 

vncserver 명령어 실행 시 추가 조건 추가

$ vncserver -localhost no

 

 

아니면 /etc/vnc.conf 변경

$ vim /etc/vnc.conf

파일 중간에 $localhost = "no"; 추가

 

1

2

3

4

5

6

7

8

9

10

11

# $localhost should the TigerVNC server only listen on localhost for

#            incoming VNC connections.

#

# Example: $localhost = "yes";

# Example: $localhost = "no";

#

# Default: $localhost = "yes"; # if $SecurityTypes does not contain any TLS*

#                              #    or X509* security types or the $SecurityTypes

#                              #    does contain at least on *None security type.

# Default: $localhost = "no";  # Otherwise

$localhost = "no";

Colored by Color Scripter

cs

 

출처: 0902.tistory.com/24

 

1. Tiger VNC Server 설치

$ sudo apt-get install tigervnc-standalone-server tigervnc-xorg-extension

2. 비밀번호 설정

$ vncpasswd

3. xstartup 작성
  "~/.vnc/xstartup" 파일을 열어 아래와 같이 작성한다.

#!/bin/sh

# Start Gnome 3 Desktop

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

vncconfig -iconic &

dbus-launch --exit-with-session gnome-session &

xstartup 파일 예제 (캡쳐)

4. 서버 실행

$ vncserver -localhost no

잘 수행되고 있는지는 "vncserver -list" 명령으로 확인할 수 있습니다.-localhost 옵션에 no를 주지 않으면 default 설정에 의해 localhost 에 의한 접근만 허용됩니다.
따라서 외부 접속을 허용하려면 해당 옵션을 주어야 합니다.

vncserver -list 명령 결과 확인 (정상적으로 생성된 Session List가 표시됨)

5. 접속 잘 되는지 확인

https://www.realvnc.com/en/connect/download/viewer/linux/

RealVNC의 Stand-alone 실행 파일로 테스트 해보았습니다.
(해당 vncviewer는 기업에서 사용할 경우 돈을 내야 합니다. 유의하시기 바랍니다.)

Download 후 chmod +x <실행파일> 로 실행 권한 부여 후 실행합니다.
IP는 가급적 localhost나 127.0.0.1 대신 공인 IP를 활용하여 외부 접속이 잘 되는지 확인하시기 바랍니다.

※ 위에서 X DISPLAY 가 :2 일 경우 5902 포트입니다.

출처: https://z-wony.tistory.com/19 [끄적끄적 프로그래밍]

'Linux > Ubuntu' 카테고리의 다른 글

Ubuntu 웹서버 구축  (0) 2021.03.21
Ubuntu VNC 설치  (0) 2021.03.20
Ubuntu 20.04 LTS Server 버전 설치  (0) 2021.03.16
Posted by iWithJoy
Linux/Ubuntu2021. 3. 16. 21:45

Ubuntu는 기본적으로 Desktop 버전과 Server 버전이 있습니다.
CentOS로 치면 표준 설치와 minimal 설치정도로 비교할 수 있을것 같네요.

차이점

Desktop 설치를 하게되면 기본적인 GUI 환경과 어느정도 유틸리티가 설치되어서 용량이 꽤 나가게 되는데
Server 버전을 설치하게 되면 최소한의 유틸리티가 설치되게 됩니다.

그래서 이번에는 제가 사용중인 ESXi OS환경에서 Ubuntu 20.04 LTS Server 버전을 설치해보도록 하겠습니다.

Ubuntu 20.04 LTS Server ISO 다운로드

우분투 공식홈페이지로 접속해서 다운로드하면됩니다.

https://ubuntu.com/download/server

다운로드가 완료되면 ESXi 데이터 스토어에 옮겨줍니다.

Ubuntu 20.04 LTS OS 설치

머신 새로만들기로 진행하겠습니다.

간단하게 이름과 OS 설정

스펙은 주고싶은대로 주시고 ISO 파일도 설정해주시면됩니다.(아까 업로드한걸로)

다 만들어졌으면 전원 켜기 버튼

기본설정

처음 language에는 한글이 없어 english로 시작합니다.

키보드는 다행히(?) 한글이있네요 찾아서 선택

네트워크 부분이 중요합니다.
여기서 고정 IP로 설정하지않으면 설치하고나서 바꿔주셔도 되긴합니다만.. 귀찮으니 여기서 합니다

Edit IPv4를 누르고 DHCP를 Manual로 변경해줍니다.
그리고 아래와 같은 형식으로 ip주소들을 넣어주면 됩니다.

프록시서버는 기본적으로 다들 사용안하실거라고 생각합니다.

미러서버도 많은데.. 귀찮으니 기본으로 갑시다.

스토리지 설정입니다.

카카오 미러로 변경: kr.archive.ubuntu.com 을 mirror.kakao.com 으로 수정

설치하실 저장장치를 선택하시고, LVM은 필요에 따라 설정하시고, 일단, 제거합니다.

설정한 장치가 포맷된다는 확인창이 표시되는데 확인 후, [ Continue ] 선택하시면 됩니다.

이제 거의 끝났습니다.
서버의 Hostname과 사용할 유저정보를 입력해주세요.

서버같은 경우 GUI가 없기 때문에 터미널로 접근하리라 생각됩니다
Open SSH는 필수입니다.

이외에 필요한것들을 선택해서 깔아주세요.
저는 웬만해서 여기서는 설치하지않고 터미널에서 직접설치합니다.

설치진행중..

다 끝나면 리부팅 하라고 나옵니다.(Cdrom Unmount하라고 나오는데 그때 Enter 한번눌러주면됩니다)

설정한 계정정보를 입력해주면 로그인 완료입니다.

기본적으로 커널 5.4 사용에 기본파일 용량으로 4.1G 정도 사용 중

출처: blog.dalso.org/linux/ubuntu-20-04-lts/9074

 

우분투 server OS에 데스크탑 GUI 설치

sudo apt-get update

sudo apt-get upgrade

 

sudo apt-get install ubuntu-desktop

를 입력하면 다운로드를 끝내고 설치까지 알아서 자동으로 진행한다.

 

설치가 끝나고나면 별도의 재부팅없이

startx

를 입력하면 익숙한 그놈(GNOME: GNU Network Object Model Environment) 데스크탑 GUI가 보일것이다. 이후 재부팅시에도 적용됩니다.

출처: blog.naver.com/grkr90/221889423598

 

우분투 저장소 변경

먼저 우분투를 포함한 각 리눅스 배포판들은 리눅스에서 돌아가는 주요 프로그램들을 저장소라는 곳에 한데 모아 제공하고 있습니다. 이러한 프로그램을 패키지라고 부르는데요. 터미널에서 간단한 명령어로 설정 없이 손쉽게 설치할 수 있습니다.

그러나 이 저장소에 올라가 있는 패키지들은 최신 버전이 아닌 경우가 많고 때에 따라서는 사용자 리눅스의 환경설정과 맞지 않아 설치가 되지 않는 경우가 있습니다.

그래서 리눅스를 잘 다루시는 분들은 직접 소스를 다운받아 자신의 리눅스 환경에 맞게 컴파일하여 설치하게 되는데요. 이렇게 하면 안정성이 굉장히 올라가게 됩니다.

그렇지만 이 컴파일 설치는 요구하는 제반지식이 상당하기 때문에 쉽게 시도할 수 있는 일은 아닙니다.

그렇다고 초심자 분들이 크게 걱정하실 필요는 없습니다. 저장소를 이용한 설치도 일반적인 환경에는 매우 안정적으로 설치되기 때문입니다.

컴파일 설치가 궁금하시다면 인터넷에 공개된 다른 유능한 분들의 설명을 참고하시기 바랍니다.

리눅스 저장소는 전세계에 미러 사이트가 있습니다. 물론 우리나라에도 여러 미러 사이트가 존재합니다.

우분투 설치 시 사는 곳을 서울로 설정해 설치할 경우 기본 저장소로 등록되어 있는 카이스트 미러로 기본 설정되어 있습니다.

 

우리나라에서는 다음의 미러 서버를 사용할 수 있습니다.

카이스트 미러 (http://ftp.kaist.ac.kr/, http://kr.archive.ubuntu.com/) ,

카카오 미러(http://mirror.kakao.com/), 네오위즈 미러(http://ftp.neowiz.com/)

하루카상 미러(https://ftp.harukasan.org/) 등이 있습니다.

카이스트 미러는 우분투 설치시 지역 설정을 서울로 할 경우 설정되는 기본 미러 서버입니다.

카카오 미러는 속도가 빠르고 안정적이어서 우분투를 사용하는 많은 사람들이 주 미러 서버로 사용하는 미러 서버입니다.

하루카상 서버는 부경대가 서버를 제공하고 있는 미러 서버입니다.

폐쇄된 미러 서버

전에 네오위즈 서버(http://ftp.neowiz.com/)도 있으나 최근 폐쇄되었습니다.

 

우분투 저장소(리포지터리) 설정 변경

우분투는 APT 저장소를 이용합니다. 이 APT라는 단어를 자주 보게 될 겁니다. 패키지를 설치하거나 저장소 패키지 목록 업데이트, 패키지 업그레이드 등 다양한 명령에 쓰입니다.

우분투 기본 저장소가 카이스트 미러로 되어 있는데요. 이것을 카카오의 미러로 변경하고자 합니다. 이유는 회선이 빠르고 안정적이기 때문입니다.

카카오 미러의 모습입니다. 보시면 아시다시피 다양한 프로그램을 지원합니다.

사실 이 다음 카카오의 미러 주소는 여러번 바뀌었습니다. ftp.daum.net에서 ftp.daumkakao.com로 다시 mirror.kakao.com로 바뀌었습니다.

이제 본격적으로 기본 저장소 설정을 변경해봅시다.

 

터미널에서 저장소 설정 변경 - CLI 방식

터미널을 열고 다음의 명령을 차례대로 입력합니다.

study@study-VirtualBox:~$ cd /etc/apt study@study-VirtualBox:/etc/apt$ sudo cp sources.list sources_original.list [sudo] study의 암호: study@study-VirtualBox:/etc/apt$

이 sources.list 파일이 저장소 주소가 설정되어 있는 파일입니다.

혹시 모를 일을 대비해 원본 파일을 백업해 둡니다.

그 다음 다음과 같이 입력합니다.

study@study-VirtualBox:/etc/apt$ sudo vi sources.list

그럼 위 그림과 같이 터미널 창이 변하게 됩니다.

이것이 터미널 상 Text 편집기 Vi의 모습입니다. 서버 관리자들은 CLI로만 서버를 관리하기 때문에 이 Vi를 자주 사용하게 됩니다.

맛보기로 vi를 이용한 편집의 예를 보여 드리기 위해 이 저장소 주소 변경을 vi로 해보겠습니다. 다음부터는 GUI 기본 편집기인 gedit를 사용하게 될 것입니다.

위 그림 상태에서 :(쌍점)을 찍어 줍니다. 그럼 아래처럼 명령어 입력 상태가 됩니다.

이 상태에서 아래와 같이 입력해줍니다.

:%s/kr.archive.ubuntu.com/mirror.kakao.com/

위 그림처럼 하단에 14줄이 변경되었다고 나옵니다.

그 상태에서 다시 :(쌍점)을 눌러 명령 입력 상태로 만듭니다.

그리고 아래와 같이 입력해줍니다.

:%s/security.ubuntu.com/mirror.kakao.com/

그럼 위 그림처럼 6줄이 변경되었다고 나올 겁니다.

그럼 잘 수정된 겁니다. 이제 저장하고 빠져나가야겠지요?

마찬가지로 :(쌍점)을 찍고 아래와 같이 입력합니다.

:wq

저장하고 끝내기의 명령어입니다.

그럼 일반적인 터미널의 프롬프트 화면으로 돌아오게 됩니다.

터미널 창을 닫고 다시 실행킵시다. 사실 이럴 필요는 없습니다만 여러분이 다음 과정을 보다 편하게 볼 수 있도록 화면을 비우는 작업입니다. 물론 터미널 화면을 깨끗이 비우는 명령이 있습니다.

study@study-VirtualBox:~$ clear

라고 입력하면 그동안 쌓인 명령들이 지워집니다.

이제 저장소 패키지 목록 업데이트와 패키지 업그레이드 작업을 할 차례입니다.

이 내용은 다음 포스트에서 이어가도록 하겠습니다.

 

우분투의 소프트웨어&업데이트 앱에서 기본 저장소 설정 변경 - GUI 방식

우분투의 소프트웨어&업데이트 앱을 실행합니다. 이때 유의할 점은 소프트웨어&업데이터 앱이 아니라는 것입니다.

 

Ubuntu 소프트웨어 탭의 다운로드 위치 항목에서 기타를 선택합니다.

 

mirror.kakao.com을 고르고 서버 선택을 눌러줍니다.

그러면 인증 확인창이 뜹니다. 암호를 입력하여 인증해줍니다.

 

그러면 위 그림처럼 바뀌게 됩니다.

다운로드 위치(미러 서버)가 바뀐 것을 확인하고 닫기 버튼을 눌러줍니다.

패키지 다운로드 시 참조할 미러 서버 정보가 바뀌게 되어 위 그림과 같은 안내창이 뜹니다.

다시 읽기 버튼을 눌러줍니다.

 

위 그림과 같이 새로 바뀐 정보를 다시 읽고 완료되면 자동으로 창들이 사라집니다.

이것으로 우분투 저장소 설정 변경 작업이 끝납니다. 이제 패키지 다운로드 속도가 굉장히 빨라질 것입니다.

 

/etc/apt/sources.list 파일 내용

Ubuntu 20.04의 sources.list 수정 전 원본

#deb cdrom:[Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423)]/ focal main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://kr.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://kr.archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://kr.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://kr.archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://kr.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://kr.archive.ubuntu.com/ubuntu/ focal universe
deb http://kr.archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://kr.archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://kr.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://kr.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://kr.archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://kr.archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://kr.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://kr.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://security.ubuntu.com/ubuntu focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.


출처: https://wnw1005.tistory.com/26 [씨실과 날실 - IT]

 

우분투 20.04 한글 입력 설정

우분투 20.04에서 한글 입력기 설치 방법입니다. 아래의 내용은 VMware Workstation Player에 자동 설치로 설치된 Ubuntu Desktop을 기준으로 설명합니다. 입력기는 기본 설치된 ibus를 사용하고 우분투는 영문을 사용하고 있습니다.


1. 우측 상단 전원 아이콘을 클릭 후 Settings를 클릭합니다.

<그림1> 환경설정

2. 좌측 Setting 리스트에서 Region & Language를 선택한 후 Manage Installed Languages를 클릭합니다.

<그림2> Region & Language

3. 우분투를 영문으로 설치할 경우 <그림3>과 같이 언어 지원을 설치하라는 메시지가 출력되게 됩니다. Install을 클릭합니다.

<그림3> Language support 설치

4. root 계정에서만 설치가 가능하므로 <그림4>와 같은 메시지가 나옵니다. 암호를 입력하고 인증 버튼을 클릭합니다. 한글 입력기를 설치 중에 <그림4>와 같은 창이 몇 번 나오게 되는데 전부 암호를 입력하고 인증 버튼을 눌러야 정상적으로 설치가 됩니다.

<그림4> Authentication window

5. Install / Remove Languages... 버튼을 클릭합니다.

<그림5> Install / Remove Languages...

6. 스크롤바를 움직여서 Korean을 찾은 후에 체크 박스를 선택하고, Apply를 클릭합니다.

<그림6> Installed Languages

7. Language for menus and windows의 스크롤바를 움직여서 한국어가 정상적으로 설치되었는지 확인하고, 재부팅을 합니다.

<그림7> 한국어 설치 확인

8. Setting -> Region & Language로 이동 후에 1번 화살표가 가리키는 버튼을 클릭하면 Add an Input Source 창이 나오게 됩니다. 여기서 Korean을 선택하고 Add 버튼을 누릅니다. 만약 여기에 Korean이 보이지 않는다면 재부팅을 하지 않았다는 것이므로 재부팅 후에 다시 확인하시면 됩니다.

<그림8> 설치된 한국어 입력기 추가

9. <그림9>의 1번 박스를 선택 후에 Add 버튼을 클릭합니다. Korean이나 Korean (101/104 key compatible)를 선택하면 한영 전환이 안되므로 꼭 Korean (Halgul)을 선택해야 합니다.

<그림9> Add an Input Source

10. <그림10>와 같이 표시되면 정상적으로 한글 입력기가 설치된 것입니다.

<그림10> Input Sources

11. 우측 상단의 영문 표시(EN)을 클릭하고 Korean (Hangul)을 선택하면 한글 입력을 할 수 있습니다. 한/영 전환은 Shift+space를 사용합니다.

<그림11> 한글입력기 선택

12. <그림12>은 기본 설치된 웹 브라우저인 파이어폭스에서 네이버에 접속한 후에 검색창에 한글을 입력한 화면입니다.

<그림12> 웹 브라우저에 한글 입력


한/영 전환키 변경 :

IBusHangul 설정은 <그림11>의 입력기 선택 메뉴에서 Setup을 클릭하면 <그림13>과 같은 창이 나오게 됩니다. <그림13>의 Hangul Toggle Key를 보면 Hangul과 Shift+space가 있습니다. 키보드의 한/영 전환 버튼이나 Shift+space 키 중 하나를 이용해서 한/영 전환을 할 수 있다는 뜻인데, VMware에 설치된 우분투의 문제인지는 몰라도 키보드의 한/영 전환 버튼은 동작하지 않습니다. 만약 Shift+space 외 다른 키를 사용하고 싶다면 Add 버튼을 눌러서 추가할 수 있습니다.

<그림13> IBusHangul Setup

<그림13>의 Add 버튼을 누른 후에 <그림14>와 같은 창이 나오면, 한/영 전환키로 사용할 키를 누릅니다. 키 조합이 정상적으로 인식되면 <그림14>의 빨간색 박스 위치에 해당되는 키 조합이 표시되게 되므로, 정상적으로 인식하는 것을 확인하고 OK 버튼을 누르면 한/영 전환키로 추가되게 됩니다.

<그림14> 한/영 전환키 추가

[출처] 우분투 20.04 한글 입력 설정|작성자 techwriter

 

o Double Commander 설치: sudo apt-get install doublecmd-gtk

 

'Linux > Ubuntu' 카테고리의 다른 글

Ubuntu 웹서버 구축  (0) 2021.03.21
Ubuntu VNC 설치  (0) 2021.03.20
Ubuntu Network & WOL  (0) 2021.03.17
Posted by iWithJoy