
200 Port command successful. Consider using pasv.
150 Ok to send data.
226 File receive OK.
66 bytes sent in 0.00 secs (708.3 kB/s)
-
Остановить сбор сетевых пакетов анализатором tcpdump. Настроить правила фильтрации на сбор информации о передаче TCP-данных между узлами 172.16.100.88 и локальной системой, указав в данном случае порт TCP источника и назначения 21. Полученные данные следует выводить на экран терминала и сохранять в файле ftp_pasv.log. Для этого необходимо применить команду
debian:/home/andrey# tcpdump -vlnXX "tcp and ip host 192.168.1.38 and host 192.168.1.43 and (dst port 21 or src port 21)" | tee ftp_pasv.log
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
-
С помощью опции -p, явно указав клиенту ftp режим пассивной передачи данных, подключиться к серверу 172.16.100.88 и скопировать текстовый файл writemetoo.txt в домашний каталог локальной системы. Добавить ФИО и строку «FTP в пассивном режиме передачи данных» в файл writemetoo.txt, используя текстовый редактор leafpad.
debian:/home/andrey# ftp -p 192.168.1.38
Connected to 192.168.1.38.
220 (vsFTPd 2.0.7)
Name (192.168.1.38:root): andrey
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> get writemetoo.txt /home/andrey/writemetoo.txt
local: /home/andrey/writemetoo.txt remote: writemetoo.txt
227 Entering Passive Mode (192,168,1,38,118,40)
150 Opening BINARY mode data connection for writemetoo.txt (256 bytes).
226 File send OK.
256 bytes received in 0.00 secs (1712.3 kB/s)
-
Воспользовавшись клиентом ftp в пассивном режиме передачи данных, записать измененный файл на сервер. Остановить сбор сетевых пакетов анализатором tcpdump и проверить содержимое файлов ftp_act.log и ftp_pasv.log
ftp> put /home/andrey/writemetoo.txt writemetoo_changed.txt
local: /home/andrey/writemetoo.txt remote: writemetoo_changed.txt
227 Entering Passive Mode (192,168,1,38,117,61)
150 Ok to send data.
226 File receive ok.
115 bytes sent in 0.00 secs (1517.6 kB/s)
-
Используя фильтр, отбирающий пересылку TCP-данных с портом источником и назначения 22, запустить анализатор сетевых пакетов командой
debian:/home/andrey# tcpdump -vlnXX "tcp and ip host 192.168.1.38 and host 192.168.1.43 and (dst port 22 or src port 22)" | tee sftp.log
-
Командой sftp student_nn©172.16.100.88 произвести подключение к SFTP-серверу. Как и ранее, переменная nn обозначает номер лабораторного ПК.
debian:/home/andrey# sftp andrey@192.168.1.38
Connecting to 192.168.1.38...
andrey@192.168.1.38's password:
sftp> mkdir .ssh
-
После успешной авторизации с помощью, встроенной в оболочку sftp команды mkdir создать каталог .ssh в домашнем каталоге пользователя на удаленной системе. Сгенерировав шифрованные ключи (п. 4.3.2 ЛР 4) на локальном узле, скопировать созданный публичный ключ (id_rsa.pub) в созданный каталог .ssh, переименовав его как authorized_keys. Разорвать соединение клиента sftp командой quit.
debian:~# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
8a:3c:2d:e1:43:98:33:ed:ce:49:b9:1e:08:c7:3d:bb root@debian
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| |
| . = |
|. B * S |
| o O B . |
| . & o |
| + O |
| .E |
+-----------------+
debian:~/.ssh# sftp root@192.168.1.38
Connecting to 192.168.1.38...
root@192.168.1.38's password:
sftp> put /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
Uploading /root/.ssh/id_rsa.pub to /root/.ssh/authorized_keys
/root/.ssh/id_rsa.pub 100% 393 0.4KB/s 00:00
sftp> quit
-
Повторно воспользовавшись командой user@host :[~]$ sftp student_nn@172.16.100.88 подключиться к серверу SFTP, используя на этот раз автоматическую авторизацию по проверке шифрованных ключей. Отметить различия между двумя способами аутентификации.
debian:~/.ssh# sftp root@192.168.1.38
Connecting to 192.168.1.38...
sftp> ls -la
drwxr-xr-x 11 root root 4096 May 6 07:00 .
drwxr-xr-x 23 root root 4096 May 5 13:14 ..
drwx------ 2 root root 4096 Apr 25 04:28 .aptitude
-rw------- 1 root root 124 May 5 05:39 .atftp_history
-rw------- 1 root root 7493 May 6 06:44 .bash_history
-rw-r--r-- 1 root root 412 Dec 16 2004 .bashrc
drwxr-xr-x 2 root root 4096 Apr 25 04:41 .debtags
drwx------ 3 root root 4096 May 6 06:36 .gconf
drwx------ 2 root root 4096 May 6 06:36 .gconfd
drwx------ 4 root root 4096 May 5 15:27 .gnome2
drwx------ 2 root root 4096 Apr 25 04:50 .gnome2_private
drwxr-xr-x 2 root root 4096 May 6 06:49 .mc
drwx------ 4 root root 4096 Apr 25 05:22 .mozilla
-rw------- 1 root root 30 May 5 17:32 .nano_history
-rw-r--r-- 1 root root 140 Nov 19 2007 .profile
-rw-r--r-- 1 root root 4165 May 5 15:27 .recently-used.xbel
drwxr-xr-x 2 root root 4096 May 6 07:14 .ssh
-
Используя текстовый редактор leafpad, создать текстовый файл securesftp.txt и внести в него строку «Этот файл передан по защищенному каналу SSH». Скопировать указанный файл на удаленный сервер, применив встроенную в клиент sftp put.
sftp> put /home/andrey/lab_5/securesftp.txt securesftp.txt
Uploading /home/andrey/lab_5/securesftp.txt to /home/andrey/securesftp.txt
/home/andrey/lab_5/securesftp.txt 100% 77 0.1KB/s 00:00
sftp>
-
Cоздать каталог data на удаленном сервере и перенести в него файлы writeme.txt, writemetoo.txt и файл securesftp.txt. Снова используя команду put, загрузить файлы flash.Ьin и update.txt с локального узла в папку data удаленного сервера SFTP.
sftp> rename writeme.txt data/writeme.txt
sftp> rename writemetoo.txt data/writemetoo.txt
sftp> rename securesftp.txt data/securesftp.txt
sftp>
sftp> put /home/andrey/lab_5/flash_new.bin flash.bin
Uploading /home/andrey/lab_5/flash_new.bin to /home/andrey/flash.bin
/home/andrey/lab_5/flash_new.bin 100% 1024KB 1.0MB/s 00:00
sftp> put /home/andrey/lab_5/update_new.txt update.txt
Uploading /home/andrey/lab_5/update_new.txt to /home/andrey/update.txt
/home/andrey/lab_5/update_new.txt 100% 1024KB 1.0MB/s 00:00
sftp> rename flash.bin data/flash.bin
sftp> rename update.txt data/update.txt
sftp>
-
Остановить сбор сетевых пакетов анализатором tcpdump и проверить содержимое файла sftp.log, отметив при этом используемые при обмене файлами TCP-сокеты.
debian:/home/andrey# tcpdump -vlnXX -r lab_5/sftp.pcap -c 10
reading from file lab_5/sftp.pcap, link-type EN10MB (Ethernet)
06:48:12.336173 IP (tos 0x0, ttl 64, id 7429, offset 0, flags [DF], proto TCP (6), length 60) 192.168.1.43.40600 > 192.168.1.38.22: S, cksum 0x7227 (correct), 2116099213:2116099213(0) win 5840 <mss 1460,sackOK,timestamp 8585608 0,nop,wscale 6>
0x0000: 0800 279e 97e7 0800 27d9 ff67 0800 4500 ..'.....'..g..E.
0x0010: 003c 1d05 4000 4006 9a15 c0a8 012b c0a8 .<..@.@......+..
0x0020: 0126 9e98 0016 7e21 1c8d 0000 0000 a002 .&....~!........
0x0030: 16d0 7227 0000 0204 05b4 0402 080a 0083 ..r'............
0x0040: 0188 0000 0000 0103 0306 ..........
06:48:12.335888 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60) 192.168.1.38.22 > 192.168.1.43.40600: S, cksum 0x43a8 (correct), 1345327858:1345327858(0) ack 2116099214 win 5792 <mss 1460,sackOK,timestamp 8768246 8585608,nop,wscale 6>
0x0000: 0800 27d9 ff67 0800 279e 97e7 0800 4500 ..'..g..'.....E.
0x0010: 003c 0000 4000 4006 b71a c0a8 0126 c0a8 .<..@.@......&..
0x0020: 012b 0016 9e98 5030 12f2 7e21 1c8e a012 .+....P0..~!....
0x0030: 16a0 43a8 0000 0204 05b4 0402 080a 0085 ..C.............
0x0040: caf6 0083 0188 0103 0306 ..........