05. 원격 접속하기 - SSH, freeNX [NAS 구축기][ubuntu 10.4]

얼렁뚱땅설명서 2012. 2. 17. 20:15


우분투에 접속하는 방법은 여러가지가 있다.
전통적인 터미널로 접속하는 방법인 SSH를 이용하는 방법과
그래픽 화면으로 접속하는 방법인  VNC와 freeNX 등이 있다.
본인은 VNC 보다는 freeNX를 추천한다. 

VNC의 설정은 여기서 확인하길 바란다.  http://ssndwind.tistory.com/36
 

freeNX는 SSH를 이용하기 때문에 가장 먼저 SSH를 설치하는 것이 우선이다.
SSH의 설치는 매우 간단하다.


username@homesvr:~$ 
sudo -s
[sudo] password for username: 
root@Team4Svr:~# apt-get install ssh
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
다음 패키지를 더 설치할 것입니다:
  openssh-server
제안하는 패키지:
  rssh molly-guard openssh-blacklist openssh-blacklist-extra
다음 새 패키지를 설치할 것입니다:
  openssh-server ssh
0개 업그레이드, 2개 새로 설치, 0개 지우기 및 0개 업그레이드 안 함.
306k바이트 아카이브를 받아야 합니다.
이 작업 후 864k바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까 [Y/n]? 
받기:1 http://kr.archive.ubuntu.com/ubuntu/ lucid-updates/main openssh-server 1:5.3p1-3ubuntu7 [305kB]
받기:2 http://kr.archive.ubuntu.com/ubuntu/ lucid-updates/main ssh 1:5.3p1-3ubuntu7 [1,256B]
내려받기 306k바이트, 소요시간 1초 (256k바이트/초)
패키지를 미리 설정하는 중입니다...
전에 선택하지 않은 openssh-server 패키지를 선택합니다.
(데이터베이스 읽는중 ...현재 125813개의 파일과 디렉토리가 설치되어 있습니다.)
openssh-server 패키지를 푸는 중입니다 (.../openssh-server_1%3a5.3p1-3ubuntu7_amd64.deb에서) ...
전에 선택하지 않은 ssh 패키지를 선택합니다.
ssh 패키지를 푸는 중입니다 (.../ssh_1%3a5.3p1-3ubuntu7_all.deb에서) ...
ureadahead에 대한 트리거를 처리하는 중입니다 ...
ureadahead will be reprofiled on next reboot
ufw에 대한 트리거를 처리하는 중입니다 ...
man-db에 대한 트리거를 처리하는 중입니다 ...
openssh-server (1:5.3p1-3ubuntu7) 설정하는 중입니다 ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
ssh start/running, process 2167

ssh (1:5.3p1-3ubuntu7) 설정하는 중입니다 ...

root@Team4Svr:~#  

이렇게 하면 간단히 설치가 끝난다.
접속을 확인하기 위해서는 Putty와 같은 프로그램을 사용하면 된다.
Host Name 에는 IP주소를 넣어도 되고, 공유기설정편에서
포트포워딩과 DDNS를 설정했다면 그 주소를 사용해도 된다. 
Host Name을 입력하고 [열기]를 클릭하면 답답한 까만 화면이 커서를 껌뻑이며 기다릴 것이다.
그래도 이 녀석은 생각보다 아름다운 놈이니 사랑해 주도록 하자. 
 

이 프로그램은 여기 
https://bitbucket.org/daybreaker/iputty/downloads 또는 
http://www.chiark.greenend.org.uk/~sgtatham/putty/  여기서 다운 받을 수 있다.




계속 이어서 freeNX를 설치한다. 방법은 아래와 같다.

root@Team4Svr:~# add-apt-repository ppa:freenx-team/ppa
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv F3A662B57D580D3A2E98E5152A8E3034D018A4CE
gpg: requesting key D018A4CE from hkp server keyserver.ubuntu.com
gpg: key D018A4CE: public key "Launchpad PPA for FreeNX Team" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
root@Team4Svr:~#
root@Team4Svr:~# apt-get update
받기:1 http://kr.archive.ubuntu.com lucid Release.gpg [189B]
기존 http://kr.archive.ubuntu.com/ubuntu/ lucid/main Translation-ko
기존 http://kr.archive.ubuntu.com/ubuntu/ lucid/restricted Translation-ko
기존 http://kr.archive.ubuntu.com/ubuntu/ lucid/universe Translation-ko
기존 http://kr.archive.ubuntu.com/ubuntu/ lucid/multiverse Translation-ko
받기:2 http://kr.archive.ubuntu.com lucid-updates Release.gpg [198B]
무시http://kr.archive.ubuntu.com/ubuntu/ lucid-updates/main Translation-ko
무시http://kr.archive.ubuntu.com/ubuntu/ lucid-updates/restricted Translation-ko
무시http://kr.archive.ubuntu.com/ubuntu/ lucid-updates/universe Translation-ko
무시http://kr.archive.ubuntu.com/ubuntu/ lucid-updates/multiverse Translation-ko
기존 http://kr.archive.ubuntu.com lucid Release
기존 http://kr.archive.ubuntu.com lucid-updates Release
기존 http://kr.archive.ubuntu.com lucid/main Packages
기존 http://kr.archive.ubuntu.com lucid/restricted Packages
기존 http://kr.archive.ubuntu.com lucid/main Sources
기존 http://kr.archive.ubuntu.com lucid/restricted Sources
기존 http://kr.archive.ubuntu.com lucid/universe Packages
기존 http://kr.archive.ubuntu.com lucid/universe Sources
기존 http://kr.archive.ubuntu.com lucid/multiverse Packages
기존 http://kr.archive.ubuntu.com lucid/multiverse Sources
기존 http://kr.archive.ubuntu.com lucid-updates/main Packages
기존 http://kr.archive.ubuntu.com lucid-updates/restricted Packages
기존 http://kr.archive.ubuntu.com lucid-updates/main Sources
기존 http://kr.archive.ubuntu.com lucid-updates/restricted Sources
기존 http://kr.archive.ubuntu.com lucid-updates/universe Packages
기존 http://kr.archive.ubuntu.com lucid-updates/universe Sources
기존 http://kr.archive.ubuntu.com lucid-updates/multiverse Packages
기존 http://ppa.launchpad.net lucid Release.gpg
무시http://ppa.launchpad.net/freenx-team/ppa/ubuntu/ lucid/main Translation-ko
기존 http://kr.archive.ubuntu.com lucid-updates/multiverse Sources
기존 http://ppa.launchpad.net lucid Release
기존 http://ppa.launchpad.net lucid/main Packages
기존 http://security.ubuntu.com lucid-security Release.gpg
무시http://security.ubuntu.com/ubuntu/ lucid-security/main Translation-ko
무시http://security.ubuntu.com/ubuntu/ lucid-security/restricted Translation-ko
무시http://security.ubuntu.com/ubuntu/ lucid-security/universe Translation-ko
무시http://security.ubuntu.com/ubuntu/ lucid-security/multiverse Translation-ko
기존 http://security.ubuntu.com lucid-security Release
기존 http://security.ubuntu.com lucid-security/main Packages
기존 http://security.ubuntu.com lucid-security/restricted Packages
기존 http://security.ubuntu.com lucid-security/main Sources
기존 http://security.ubuntu.com lucid-security/restricted Sources
기존 http://security.ubuntu.com lucid-security/universe Packages
기존 http://security.ubuntu.com lucid-security/universe Sources
기존 http://security.ubuntu.com lucid-security/multiverse Packages
기존 http://security.ubuntu.com lucid-security/multiverse Sources
내려받기 387바이트, 소요시간 5초 (74바이트/초)
패키지 목록을 읽는 중입니다... 완료
root@Team4Svr:~#
root@Team4Svr:/etc/init# aptitude install freenx-server
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다
상태 정보를 읽는 중입니다... 완료
Reading extended state information
Initializing package states... 완료
Writing extended state information... 완료
The following NEW packages will be installed:
  expect{a} freenx-server freenx-session-launcher{a} tcl8.5{a}
0 packages upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/1,984kB of archives. After unpacking 5,722kB will be used.
Do you want to continue? [Y/n/?]
Writing extended state information... 완료
패키지를 미리 설정하는 중입니다...
전에 선택하지 않은 tcl8.5 패키지를 선택합니다.
(데이터베이스 읽는중 ...현재 132202개의 파일과 디렉토리가 설치되어 있습니다.)
tcl8.5 패키지를 푸는 중입니다 (.../tcl8.5_8.5.8-2_amd64.deb에서) ...
전에 선택하지 않은 expect 패키지를 선택합니다.
expect 패키지를 푸는 중입니다 (.../expect_5.44.1.14-5_amd64.deb에서) ...
전에 선택하지 않은 freenx-server 패키지를 선택합니다.
freenx-server 패키지를 푸는 중입니다 (.../freenx-server_0.7.3.git110520.3884279-0ubuntu1ppa4_amd64.deb에서) ...
전에 선택하지 않은 freenx-session-launcher 패키지를 선택합니다.
freenx-session-launcher 패키지를 푸는 중입니다 (.../freenx-session-launcher_0.7.3.git110520.3884279-0ubuntu1ppa4_amd64.deb에서) ...
man-db에 대한 트리거를 처리하는 중입니다 ...
ureadahead에 대한 트리거를 처리하는 중입니다 ...
tcl8.5 (8.5.8-2) 설정하는 중입니다 ...

expect (5.44.1.14-5) 설정하는 중입니다 ...

freenx-server (0.7.3.git110520.3884279-0ubuntu1ppa4) 설정하는 중입니다 ...
freenx-server start/running

freenx-session-launcher (0.7.3.git110520.3884279-0ubuntu1ppa4) 설정하는 중입니다 ...

libc-bin에 대한 트리거를 처리하는 중입니다 ...
ldconfig deferred processing now taking place
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다
상태 정보를 읽는 중입니다... 완료
Reading extended state information
Initializing package states... 완료
Writing extended state information... 완료
root@Team4Svr:~#  



명령어 3번만 입력하면 설치는 간단히 끝난다. 그러나 손은 조금더 봐야 한다.
간략히 말해, 설정파일을 열어서 3군데를 편집하고, 키파일을 만들어 주면 nxserver를 사용할 수 있는 상태가 된다.


root@Team4Svr:~#
root@Team4Svr:~# cd /etc/nxserver
root@Team4Svr:/etc/nxserver# ls
node.conf  node.conf.d  nxacl  nxcheckload  nxshadowacl
root@Team4Svr:/etc/nxserver# vi node.conf

#########################################################################
# General FreeNX directives
#########################################################################

# The host name which is used by NX server. It's should be used if it's
# different than the default hostname (as returned by `hostname`)
SERVER_NAME="$(hostname)" <--- # 제거

# The node ip which is used by NX Node in unecnrypted session mode.
# Set it if you want to use a specific external ip or the autodetection
# is not working.
#EXTERNAL_PROXY_IP=""

# The port number where local 'sshd' is listening.
SSHD_PORT=22 <--- # 제거


#########################################################################
# Authentication / Security directives
#########################################################################

# Authentication directives

# This adds the usermode to the possible authentication methods
# Usermode means that a user can start the nxserver as his shell
# and connect directly to the right server via a custom client.
#ENABLE_USERMODE_AUTHENTICATION="0"

# This adds the passdb to the possible authentication methods
#ENABLE_PASSDB_AUTHENTICATION="0"

# This adds SSH to the possible authentication methods. For it to work sshd
# must be set up at localhost accepting password authentication.
ENABLE_SSH_AUTHENTICATION="1" <--- # 제거

# This adds SU to the possible authentication methods. For it to work the
# "nx" user must be in the wheel (RedHat, Fedora) or the users group (SUSE)
# and the user logging in must have a valid shell that accepts the -c
# parameter.
#ENABLE_SU_AUTHENTICATION="0"

----
root@Team4Svr:/etc/nxserver# /usr/lib/nx/nxkeygen
Unique key generated; your users must install

    /var/lib/nxserver/home/.ssh/client.id_dsa.key

on their computers.
root@Team4Svr:/etc/nxserver# cp /var/lib/nxserver/home/.ssh/client.id_dsa.key client.id_dsa.key
root@Team4Svr:/etc/nxserver# ls
client.id_dsa.key  node.conf  node.conf.d  nxacl  nxcheckload  nxshadowacl
root@Team4Svr:/etc/nxserver# cat client.id_dsa.key
-----BEGIN DSA PRIVATE KEY-----
MIIBuwIBAAKBgQD4guNuz7zayUfzNlroQ+lGbmM3kbJSPALDWDsN1t2gop3i5xK2
SV1TaoBGNlsL4IWqn0bGjSZ3ulNKkohO20ltGG3oId6jDlSbc2IvhBrybNonc6rs
x/63NcXnp8rN1WeuUrHj+uvsgsHiBGc7m5Mb7Jub31g6ndBgUjaIqLQMFwIVANZy
CDqEGS9NlGdeSO5D2pNDaCVxAoGAFlsuFWVJiRN9boAw46zjlp/TsyfQE5jjakNv
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
UYomTy3IBJgJCOZS7KY9rqeDoB05RNsD3Lmh4zGJt2wy8olXYWA36mHwGwovrwJl
/2vGdiMCgYEAsE4q3qOQhxS3IiMcSlRXRCHHfL+WXmAwhZo6y+Xf9hU5l69txoC8
Nr1tmkAqqf7K73MiXgC8DWgbtMn5M2nWqOiR4bmGt369mWsbQJvWyLAEU4En5q/4
DB0Y2+C9Ho3KrCHKZxINT8Gfr31p3QmEBRXhdu31XKzNo3KUOBjznIECFBlZ6Z0F
coC8jtYnYzVGV9uadhsU
-----END DSA PRIVATE KEY-----
root@Team4Svr:/etc/nxserver#
root@Team4Svr:/etc/nxserver# service freenx-server restart
freenx-server start/running
root@Team4Svr:/etc/nxserver#


맨 마지막에 Client.id_dsa.key의 내용은 잘 복사해 둬야 한다.
이것은 FreeNX Client를 이용한 접속에서 사용해야 한다.

설치가 끝나면 FreeNX Client 프로그램을 설치하자.
FreeNX Client는 다음 주소에서 받을 수 있다.
여기서 받을 수 있다. --> 
http://www.nomachine.com/download.php 

다운받아 설치하고 나면, 아래의 그림처럼 Session 에 서버이름을 만들어주고,
Host 입력 칸에 서버 주소를 적어준다. 포트포워딩과 DDNS를 설정했으며, 그 주소를 적어 주어도 된다.
그러면 인터넷이 연결된 모든 장소에서도 접근할 수 있을 것이다.




Next 버튼을 클릭하여 다음 화면이 나오면 자신의 환경에 맞는  desktops을 선택하면 된다.
우분투 10.04는 기본이 GNOME이다. 선택을 완료했으면 다시 Next를 클릭한다. 

 



Finish를 클릭하고 다음으로 넘어오면 아래와 같은 화면을 만날 수 있다. 
그러면, 먼저 Configure... 버튼을 누르고, 다시 Key... 버튼을 누른 다음
nxserver 서버 설치 마지막 단계에서 복사해둔 client.id_dsa.key 값을 입력하고 저장하면 된다.
이제 아이디와 패스워드를 입력하고 Login 버튼은 누르면
당신의 우분투 서버와의 감동적인 만남을 어디서든 할수가 있다.