Tải bản đầy đủ (.pdf) (8 trang)

Topic 9 Remote Server Managerment

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (593.1 KB, 8 trang )

Topic 9: Remote server management
Telnet server
Ssh – Secure shell
VNC server

132

Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ


Điều khiển linux server từ xa
1. Secure Shell
Chương trình telnet cho phép người dùng đăng nhập từ xa vào hệ thống. Nhưng khuyết điểm của
chương trình này là tên người dùng và mật khẩu gửi qua mạng không được mã hố. Do đó, rất dễ bị
tấn cơng. Phần mềm ssh là một sự hỗ trợ mới của linux nhằm khắc phục nhược điểm của telnet. Nó
cho phép bạn đăng nhập từ xa vào hệ thống linux và mật khẩu sẽ được mã hố.
Mặc định khi cài đặt linux thì ssh đã được cài đặt
- Kiểm tra ssh đã được cài đặt hay chưa:
[root@may1 Packages]# rpm -qa | grep openssh
openssh-7.4p1-11.el7.x86_64
openssh-server-7.4p1-11.el7.x86_64
openssh-clients-7.4p1-11.el7.x86_64
Kiểm tra port 22
[root@localhost ~]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address
Foreign Address
name
tcp
0 0 0.0.0.0:22
0.0.0.0:*


LISTEN
tcp
0 0 127.0.0.1:25
0.0.0.0:*
LISTEN
tcp6
0
0 :::22
:::*
LISTEN
tcp6
0
0 :::23
:::*
LISTEN
tcp6
0
0 ::1:25
:::*
LISTEN

State

PID/Program

1265/sshd
2377/master
1265/sshd
3965/xinetd
2377/master


[root@localhost ~]# systemctl status sshd
sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
Active: active (running) since Sun 2015-04-26 15:10:18 ICT; 1h 18min ago
Main PID: 1265 (sshd)
CGroup: /system.slice/sshd.service
ââ1265 /usr/sbin/sshd -D
Apr 26 15:10:18 localhost.localdomain systemd[1]: Started OpenSSH server daemon.
Apr 26 15:10:18 localhost.localdomain sshd[1265]: Server listening on 0.0.0.0 port 22.
2. SSH client
Client sử dụng các cách sau để kết nới đến SSH server
2.1 Truy cập ssh server từ Linux:
[root@may1 ~]# ssh
's password:
Last login: Sun Apr 26 15:35:24 2015 from 192.168.1.10Last login: Tue Jul 10 23:09:51
2012 from 192.168.1.2
Nếu muốn ssh với account khác root thì thêm vào option –l như sau:


[root@may1 ~]# ssh –l u1 192.168.1.23
- Sử dụng lệnh scp để thực hiện sao chép qua ssh:
[root@may1 ~]# scp -r /dulieu 192.168.1.20:/data
2.2 SSH Secure Shell Client
Trên windows cài chương trình SSH Secure Shell Client

Chọn add profile, edit profile. khai báo các thông số sau:

134


Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ


Chọn OK
Chọn connection m1 => chọn Connect

Nhập vào password cho account root, chọn OK
Sử dụng SSH Secure File Transfer Client chép dữ liệu giữa windows và linux

3 Cấu hình SSh
3.1 Giới hạn user truy cập ssh
- Chỉ cho root và u1 được kêt nối đến ssh server


[root@may1 ~]# vi /etc/ssh/sshd_config
Banner /etc/ssh/banner.txt
AllowUsers u1 root
[root@may1 ~]# service sshd restart
3.2 Cấm user root dùng ssh
# vi /etc/ssh/sshd_config
49 PermitRootLogin no
# systemctl restart sshd
Tại máy client truy cập sẽ báo lỗi
[root@may1 ~]# ssh
's password:
Permission denied, please try again.
User thường vẫn có thể dùng ssh và su qua user root
3.3 SSH X11 Forwarding
Tại máy server
# vi /etc/ssh/sshd_config

115 X11Forwarding yes
116 X11DisplayOffset 10
# systemctl restart sshd
Tại máy Linux client, startx
#si#sh –XC
# eval `dbus-launch --sh-syntax`
# export DBUS_SESSION_BUS_ADDRESS
# export DBUS_SESSION_BUS_PID
# gnome-system-monitor

136

Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ


Máy windows:
- Cài sfnet_xming
- Mở putty, chọn select X11, chọn "Enable X11 forwarding"
- Tiến hành kết nối ssh đến máy linux

Chạy ứng dụng:
#oocalc hoặc
#gnome-window-properties
4 Cho phép truy cập SSH server khơng u cầu nhập passowrd
- Sửa file cấu hình trên server thiết lập 2 thuộc tính sau:
[root@may1 ~]# vi /etc/ssh/sshd_config
55 PubkeyAuthentication yes
59 AuthorizedKeysFile
.ssh/authorized_keys
- Tạo key tại máy Client:


- Copy key của Client lên Server:


[root@may1 ~]# scp -r /root/.ssh/ 192.168.1.20:/root
- Trên server copy file id_rsa.pub thành file mới đổi tên thành authorized_keys:
[root@may1 .ssh]# cp /root/.ssh/id_dsa.pub /root/.ssh/authorized_keys
- Restart lại sshd daemon trên server:
[root@may1 .ssh]# service sshd restart
- Truy cập SSH từ Client:
[root@may1 ~]# ssh 192.168.1.101
Last failed login: Sun Apr 26 18:24:03 ICT 2015 from 192.168.1.10 on ssh:notty
There were 2 failed login attempts since the last successful login.
Last login: Sun Apr 26 18:22:49 2015 from 192.168.1.10

5. VNC
Điều khiển server từ xa qua giao diện đồ họa
- Cài đặt tigervnc-server
tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64
tigervnc-license-1.2.80-0.30.20130314svn5065.el7.noarch
tigervnc-server-minimal-1.2.80-0.30.20130314svn5065.el7.x86_64
- Đặt password cho vnc server
[root@localhost ~]# vncserver
You will require a password to access your desktops.
Password:213456
Verify:123456
- Khởi động vns server, run with diplay number '1', screen resolution '800x600', color depth '24'
#vncserver :1 -geometry 800x600 -depth 24
- Tại máy windows, cài TightVNC hoặc UltraVNC, tiến hành kết nối


- Nhập password của vnc

138

Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ


- Kết nối thành công

Linux: Remote desktop windows
pcsc-lite-libs-1.5.2-8.el6_3.i686
libao-devel-0.8.8-7.1.el6.i686
ctapi-common-1.1-6.1.el6.i686
openct-0.6.19-4.el6.i686
pcsc-lite-1.5.2-8.el6_3.i686
pcsc-lite-openct-0.6.19-4.el6.i686
rdesktop-1.6.0-8.el6_0.1.i686
6. Kết nối đến windows với giao thức RDP
Máy linux cài các gói:
pcsc-lite-libs-1.8.8-5.el7.x86_64.rpm
freerdp-libs-1.0.2-5.el7_1.1.x86_64
freerdp-1.0.2-5.el7_1.1.x86_64
freerdp-plugins-1.0.2-5.el7_1.1.x86_64
Máy windows check Enable remote destop, tắt firewall
Tại máy linux, kết nối đến windows
# xfreerdp -g 800x600 -u administrator 192.168.1.101




×