1. Trang chủ
  2. » Công Nghệ Thông Tin

Phần 1: Cấu hình VNC server/viewer doc

5 605 3

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

Phần 1: Cấu hình VNC server/viewer Nguồn: http://www.bobpeers.com/linux/vnc.php (Bài viết được minh hoạ với CentOS 5 - server và Fedora 8 - client) VNC - Virtual Networked Computing là một cách kiểm soát máy tính từ xa như là khi bạn ngồi trước nó. Trong thế giới Windows nó được biết đến với tên gọi remote desktop. Bước 1: Enable Remote desktop Vào System -> Preferences -> Internet and Network -> Remote Desktop. Đánh dấu chọn vào Allow other users to view your desktop và Require the users to enter this password -> sau đó nhập password vào Bước 2: Kiểm tra xem vnc và vnc-server đã được cài chưa Code: $ rpm -qa | grep vnc vnc-server-4.1.2-23.fc8 vnc-4.1.2-23.fc8 Nếu chưa hãy cài chúng qua yum Bước 3: Thêm users Mở /etc/sysconfig/vncservers với quyền root và bỏ chú thích 2 dòng cuối để trở thành: # The VNCSERVERS variable is a list of display:user pairs. # # Uncomment the lines below to start a VNC server on display :2 # as my 'myusername' (adjust this to your own). You will also # need to set a VNC password; run 'man vncpasswd' to see how # to do that. # # DO NOT RUN THIS SERVICE if your local area network is # untrusted! For a secure way of using VNC, see # <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>. # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP. # Use "-nohttpd" to prevent web-based VNC clients connecting. # Use "-localhost" to prevent remote VNC clients connecting except when # doing so through a secure tunnel. See the "-via" option in the # `man vncviewer' manual page. VNCSERVERS="1:quanta" VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" Dòng VNCSERVERS="1:quanta" sẽ sets up một user cho vnc server, bạn có thể thêm bao nhiêu users tuỳ ý. Dòng VNCSERVERARGS[1] set các tham số cho user 1 Chú ý rằng: session number user cũng nói cho chúng ta biết cổng mà vncserver sẽ lắng nghe. Nhớ rằng, Gnome Remote Desktop hỏi chúng ta để sử dụng computername:0 như một chuỗi kết nối, session number sẽ được cộng thêm 5900 để ra cổng mà vncserver sẽ lắng nghe. Trong trường hợp này chúng ta cần sử dụng cổng 5901, nên chúng ta dùng session 1. Bạn có thể sử dụng bất kỳ số nào, ví dụ: VNCSERVERS="2000:bobpeers" VNCSERVERARGS[2000]="-geometry 1024x768 -depth 16" Lúc này thì chúng ta phải dùng cổng 7900 Bước 4: Đặt password Để tăng độ bảo mật, bạn cần thêm 1 password trước khi kết nối được thi hành, từ Terminal gõ: Code: $ vncpasswd Password: Verify: Lệnh này sẽ tạo 1 thư mục ẩn với tên gọi .vnc trong home, để chứa password file Bước 5: Khởi động server với các tuỳ chọn Để khởi động server, bạn gõ "vncserver" kèm theo session mà bạn muốn khởi động (nếu bạn gán nhiều hơn 1 entry trong /etc/sysconfig/vncservers) Code: $ vncserver :1 New 'localhost.localdomain:1 (quanta)' desktop is localhost.localdomain:1 Starting applications specified in /home/quanta/.vnc/xstartup Log file is /home/quanta/.vnc/localhost.localdomain:1.log Lúc này server đã khởi động và bạn có thể kết nối được rồi, tuy nhiên rất có thể bạn chỉ có được 1 màn hình xám xịt, bởi theo mặc định kết nối không tạo một session mới của X để khởi động. Để fix điều này, chúng ta cần chỉnh lại startup script trong .vnc file của home: $ vi ~/.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 & Tiếp theo bạn cần restart vncserver để thay đổi có hiệu lực: Code: $ vncserver -kill :1 Killing Xvnc process ID 13728 Code: $ vncserver :1 New 'localhost.localdomain:1 (quanta)' desktop is localhost.localdomain:1 Starting applications specified in /home/quanta/.vnc/xstartup Log file is /home/quanta/.vnc/localhost.localdomain:1.log Bước 6: Sử dụng vncviewer Code: $ vncviewer 192.168.1.3:5901 Lệnh này sẽ mở một hộp thoại để bạn nhập password: Nhập password và Enter, bạn sẽ thấy màn hình của CentOS 5: Dừng vncserver Có 2 cách: Code: $ /sbin/service vncserver stop Shutting down VNC server: 1:quanta [ OK ] Code: $ vncserver -kill :1 Killing Xvnc process ID 13728 Cho phép kết nối từ xa Nếu muốn cho phép kết nối từ xa thì bạn phải thực hiện như sau: Add port System -> administration -> Firewall and Linux -> chọn Firewall Options tab -> Other ports -> Add button, nhập 5901 với giao thức là tcp -> OK Chỉnh sửa iptables để mở cổng $ sudo vim /etc/sysconfig/iptables -A FORWARD -j RH-Firewall-1-INPUT -A RH-Firewall-1-INPUT -i lo -j ACCEPT -A RH-Firewall-1-INPUT -p icmp icmp-type any -j ACCEPT -A RH-Firewall-1-INPUT -p 50 -j ACCEPT -A RH-Firewall-1-INPUT -p 51 -j ACCEPT -A RH-Firewall-1-INPUT -p udp dport 5353 -d 224.0.0.251 -j ACCEPT -A RH-Firewall-1-INPUT -p udp -m udp dport 631 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp dport 631 -j ACCEPT -A RH-Firewall-1-INPUT -m state state ESTABLISHED,RELATED -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m tcp -p tcp dport 21 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m tcp -p tcp dport 25 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m tcp -p tcp dport 2049 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m tcp -p tcp dport 22 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m udp -p udp dport 137 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m udp -p udp dport 138 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m tcp -p tcp dport 139 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m tcp -p tcp dport 445 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m tcp -p tcp dport 443 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m tcp -p tcp dport 23 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m tcp -p tcp dport 80 -j ACCEPT -A RH-Firewall-1-INPUT -m state state NEW -m tcp -p tcp dport 5901 -j ACCEPT -A RH-Firewall-1-INPUT -j REJECT reject-with icmp-host-prohibited COMMIT Restart lại iptables service Code: $ sudo /sbin/service iptables restart Flushing firewall rules: [ OK ] Setting chains to policy ACCEPT: filter [ OK ] Unloading iptables modules: [ OK ] Applying iptables firewall rules: [ OK ] Loading additional iptables modules: ip_conntrack_netbios_n[ OK ] Kết nối từ xa: Bây giờ, từ máy client, chạy vncviewer với IP của host, theo sau là cổng: Code: $ vncviewer 192.168.1.3:5901 Nếu việc kết nối chậm, bạn có thể chỉnh lại depth color hoặc screen resolution trong /etc/sysconfig/vncservers . Phần 1: Cấu hình VNC server/viewer Nguồn: http://www.bobpeers.com/linux /vnc. php (Bài viết được minh hoạ với CentOS 5 - server và Fedora 8 - client) VNC - Virtual Networked. sẽ thấy màn hình của CentOS 5: Dừng vncserver Có 2 cách: Code: $ /sbin/service vncserver stop Shutting down VNC server: 1:quanta [ OK ] Code: $ vncserver -kill :1 Killing Xvnc process. tra xem vnc và vnc- server đã được cài chưa Code: $ rpm -qa | grep vnc vnc- server-4.1.2-23.fc8 vnc- 4.1.2-23.fc8 Nếu chưa hãy cài chúng qua yum Bước 3: Thêm users Mở /etc/sysconfig/vncservers

Ngày đăng: 29/07/2014, 03:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w