VNC 설정은 어떻게 하나요?
💡 요약 정리
- X-windows가 설치된 서버에 VNC를 설정하면 원격 GUI 접속이 가능합니다.
vncserver명령어 실행 후 비밀번호를 설정해야 합니다..vnc/xstartup설정 수정, 불필요한 파일 정리, 접속 시도 과정이 필요합니다.- 모든 작업은 루트(root) 권한에서 진행해야 하며, 정확한 명령어 사용이 중요합니다.
1. vncserver 명령 실행
- vnc 접속 시 사용할 비밀번호를 설정합니다.
[root@localhost Desktop]# vncserver
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /root/.Xauthority
New 'localhost:1 (root)' desktop is localhost:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost:1.log
2. /root/.vnc 디렉토리로 이동하여 pid 및 log 파일 확인
[root@localhost ~]# cd .vnc/
[root@localhost .vnc]# ls
passwd localhost:1.log localhost:1.pid xstartup
3. /root/.vnc/xstartup 파일의 4, 5번째 줄 주석 제거
[root@localhost .vnc]# cat /root/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER <---- 주석제거
# exec /etc/X11/xinit/xinitrc <---- 주석제거
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
[root@localhost .vnc]#
4. VNC 프로세스 확인 및 종료
[root@localhost .vnc]# ps ax | grep vnc
11880 pts/0 S 0:00 Xvnc :1 -desktop localhost:1 (root) -httpd /usr/share/vnc/classes -auth /root/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -pn
11889 pts/0 S 0:00 vncconfig -iconic
11927 pts/0 S+ 0:00 grep vnc
[root@localhost .vnc]# kill -9 11880
5. log 파일 및 pid 파일 삭제
[root@localhost .vnc]# ls
passwd localhost:1.log localhost:1.pid xstartup
[root@localhost .vnc]# rm localhost:1.*
rm: remove regular file `localhost:1.log'? y
rm: remove regular file `localhost:1.pid'? y
6. /tmp 디렉토리에서 lock 파일 삭제
[root@localhost .vnc]# cd /tmp/
[root@localhost tmp]# ls -al
total 56
drwxrwxrwt 7 root root 4096 Oct 13 09:53 .
drwxr-xr-x 25 root root 4096 Oct 12 18:08 ..
drwxrwxrwt 2 root root 4096 Oct 12 18:08 .font-unix
drwx------ 2 root root 4096 Oct 12 18:11 gconfd-root
srw-rw-rw- 1 root root 0 Oct 12 18:08 .gdm_socket
drwxrwxrwt 2 root root 4096 Oct 12 18:11 .ICE-unix
srwxr-xr-x 1 root root 0 Oct 12 18:09 mapping-root
drwx------ 2 root root 4096 Oct 12 18:11 orbit-root
-rw------- 1 root root 1024 Oct 12 08:41 .rnd
-r--r--r-- 1 root root 11 Oct 12 18:11 .X0-lock
drwxrwxrwt 2 root root 4096 Oct 13 09:53 .X11-unix
-r--r--r-- 1 root root 11 Oct 13 09:53 .X1-lock
[root@localhost tmp]# rm .X1-lock
rm: remove regular file `.X1-lock'? y
[root@localhost tmp]# cd .X11-unix/
[root@localhost .X11-unix]# ls -al
total 12
drwxrwxrwt 2 root root 4096 Oct 13 09:58 .
drwxrwxrwt 10 root root 4096 Oct 13 09:58 ..
srwxrwxrwx 1 root root 0 Oct 13 09:53 X1
[root@localhost .X11-unix]# rm -rf *
7. vncserver 명령 재실행
[root@localhost .vnc]# vncserver
New 'localhost:1 (root)' desktop is localhost:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost:1.log
[root@localhost .vnc]#
8. vncviewer를 통해 접속
-
접속 시
ip:세션번호형식으로 입력합니다.예:
192.168.51.17:1