IP 설정

# vi /etc/netplan/00-installer-config.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
   ens33:
    dhcp4: no
    addresses:
    - 192.168.0.22/24
    gateway4: 192.168.0.2
    nameservers:
     addresses: [8.8.8.8, 8.8.4.4]

# netplan apply

apt 저장소 변경

# vi /etc/apt/sources.list

mirror.kakao.com/ubuntu

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

apt update / apt upgrade

# apt update && apt upgrade
# init 6

xfce4 , vnc-server 설치

# apt install xfce4 xfce4-goodies gnome-icon-theme xfonts-base xfonts-100dpi xfonts-75dpi tasksel \
tigervnc-standalone-server tigervnc-xorg-extension

lightdm 선택

# init 6

vnc-server 최초실행

test@ubunut-server:~$ vncserver

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
/usr/bin/xauth:  file /home/test/.Xauthority does not exist

New 'ubunut-server:1 (test)' desktop at :1 on machine ubunut-server

Starting applications specified in /etc/X11/Xvnc-session
Log file is /home/test/.vnc/ubunut-server:1.log

Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/test/.vnc/passwd :1 to connect to the VNC server.

vncserver: Failed command '/etc/X11/Xvnc-session': 256!

=================== tail -15 /home/test/.vnc/ubunut-server:1.log ===================

Xvnc TigerVNC 1.10.0 - built Apr  9 2020 06:49:31
Copyright (C) 1999-2019 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12008000, The X.Org Foundation

Thu Sep 24 18:05:37 2020
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on local interface(s), port 5901
 vncext:      created VNC server for screen 0
 ComparingUpdateTracker: 0 pixels in / 0 pixels out
 ComparingUpdateTracker: (1:-nan ratio)
X connection to :1 broken (explicit kill or server shutdown).
Killing Xtigervnc process ID 1273... which seems to be deadlocked. Using SIGKILL!

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

Starting applications specified in /etc/X11/Xvnc-session has failed.
Maybe try something simple first, e.g.,
        tigervncserver -xstartup /usr/bin/xterm
test@ubunut-server:~$

xstartup 스크립트 생성

test@ubuntu-server:~$ vi .vnc/xstartup

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

chmod +x .vnc/xstartup

vnc-server 실행확인

test@ubuntu-server:~$ vncserver -list

TigerVNC server sessions:

X DISPLAY #     RFB PORT #      PROCESS ID
:1              5901            18742
test@ubuntu-server:~$

test@ubuntu-server:~$ vncserver -kill :1
test@ubuntu-server:~$ vncserver -list

vncserver systemd 스크립트 생성

test@ubuntu-server:~$ sudo vi /etc/systemd/system/vncserver@.service

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

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

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

test@ubunut-server:~$ sudo systemctl daemon-reload
test@ubunut-server:~$ sudo systemctl enable vncserver@1
Created symlink /etc/systemd/system/multi-user.target.wants/vncserver@1.service → /etc/systemd/system/vncserver@.service.
test@ubunut-server:~$ sudo init 6

시스템 리부팅후 vnc 실행 확인

test@ubuntu-server:~$ sudo systemctl status vncserver@1   

test@ubunut-server:~/.vnc$ vncserver -list

TigerVNC server sessions:

X DISPLAY #     RFB PORT #      PROCESS ID
:1              5901            931
test@ubunut-server:~/.vnc$ netstat -antp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      931/Xtigervnc
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -
tcp        0    816 192.168.0.22:22         192.168.0.1:3455        ESTABLISHED -
tcp6       0      0 :::5901                 :::*                    LISTEN      931/Xtigervnc
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 ::1:631                 :::*                    LISTEN      -
test@ubunut-server:~/.vnc$

필수패키지 설치 및 시스템 절전모드 데몬 disable

# 필수 패키지 설치 
test@ubunut-server:~$ sudo apt install net-tools wget sysstat

# 필수 데몬 disable ( 시스템 절전모드 실행됨)
test@ubunut-server:~$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
Created symlink /etc/systemd/system/sleep.target → /dev/null.
Created symlink /etc/systemd/system/suspend.target → /dev/null.
Created symlink /etc/systemd/system/hibernate.target → /dev/null.
Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/null.
test@ubunut-server:~$
Last modified: 2022-07-09

Author

Comments

Write a Reply or Comment