Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ОСИ_Ведерников.doc
Скачиваний:
1
Добавлен:
01.03.2025
Размер:
259 Кб
Скачать
☆

Лабораторная работа № 10. Использование пакета OpenSsh.

Цель: ознакомиться с удаленной работой по сети по протоколу ssh с использованием пакета OpenSSH.

1. Генерация RSA-ключа, копирование файла .ssh/test.pub в файл .ssh/authorized_keys на удаленной машине (перенесем с помощью флешки).

sergey@sergey-VirtualBox1:~$ ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/home/user/.ssh/id_rsa): test

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in test.

Your public key has been saved in test.pub.

The key fingerprint is:

cb:c8:7a:84:92:2e:3c:48:c7:d6:14:1e:b4:1c:5f:12 flagman@ubuntu2

sergey@sergey-VirtualBox2:~$ cp ~/.ssh/test.pub /media/usb

sergey@sergey-VirtualBox1:~$ cp /media/usb/test.pub ~/.ssh/authorized_keys

2. Заходим на другую машину с помощью ssh.

sergey@sergey-VirtualBox 2:~/.ssh$ ssh 10.98.27.1

The authenticity of host '10.98.27.1 (10.98.27.1)' can't be established.

RSA key fingerprint is cb:c8:7a:84:92:2e:3c:48:c7:d6:14:1e:b4:1c:5f:12.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '10.98.27.1' (RSA) to the list of known hosts.

sergey@10.98.27.1's password: *********

Linux ubuntu1 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686

The programs included with the Ubuntu system are free software;

the exact distribution terms for each program are described in the

individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by

applicable law.

Last login: Mon Dec 24 18:20:52 2012 from ubuntu2.local

sergey@sergey-VirtualBox1:~$

3. Запускаем программу ssh-agent при помощи команды eval ‘ssh-agent’ , добавляем в хранилище свой ключ. Заходим при помощи программы ssh на другой компьютер.

sergey@sergey-VirtualBox2:~/.ssh$ eval 'ssh-agent'

SSH_AUTH_SOCK=/tmp/ssh-EYhEMn5981/agent.5981; export SSH_AUTH_SOCK;

SSH_AGENT_PID=5982; export SSH_AGENT_PID;

echo Agent pid 5982;

sergey@sergey-VirtualBox2:~/.ssh$ ssh-add test

Enter passphrase for test:

Identity added: test (test)

sergey@sergey-VirtualBox2:~/.ssh$ ssh 10.98.27.1

Linux ubuntu1 2.6.22-14-generic #1 SMP Mon Dec 24 23:05:12 YEKT 2012 i686

The programs included with the Ubuntu system are free software;

the exact distribution terms for each program are described in the

individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by

applicable law.

Last login: Mon Dec 24 18:23:24 2012 from ubuntu2.local

4. Выполните команду ls /etc на компьютере ubuntu1, отсортируйте результат на любом другом компьютере и сохраните результат в файле отчета.

sergey@sergey-VirtualBox1:~$ ls /etc >> result

sergey@sergey-VirtualBox2:~$ ssh 10.98.27.1

Linux ubuntu198 2.6.2-14-generic #1 SMP Mon Dec 24 23:05:12 YEKT 2012 i68

The programs included with the Ubuntu system are free software;

the exact distribution terms for each program are described in the

individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by

applicable law.

Last login: Mon Dec 24 18:29:07 2012 from ubuntu2.local

sergey@sergey-VirtualBox1:~$ sort result >> result

result:

acpi

adduser.conf

adjtime

aliases

alternatives

anacrontab

apm

apparmor

apparmor.d

apport

apt

at.deny

avahi

bash.bashrc

bash_completion

bash_completion.d

belocs

bindresvport.blacklist

blkid.tab

blkid.tab.old

bluetooth

bogofilter.cf

bonobo-activation

brlapi.key

brltty

brltty.conf

calendar

chatscripts

compizconfig

console-setup

console-tools

cron.d

cron.daily

cron.hourly

cron.monthly

crontab

cron.weekly

cups

dbus-1

debconf.conf

debian_version

default

defoma

deluser.conf

devfs

dhcp3

dictionaries-common

discover.conf

discover.conf-2.6

discover.d

dpkg

emacs

environment

esound

event.d

fdmount.conf

firefox

fonts

foomatic

fstab

fuse.conf

gai.conf

gamin

gconf

gdm

gnome

gnome-app-install

gnome-system-tools

gnome-vfs-2.0

gnome-vfs-mime-magic

groff

group

group-

grub.d

gshadow

gshadow-

gtk-2.0

hal

hdparm.conf

hesiod.conf

host.conf

hostname

hosts

hosts.allow

hosts.deny

hotplug

hp

init.d

initramfs-tools

inputrc

iproute2

issue

issue.net

java

kernel-img.conf

laptop-mode

ldap

ld.so.cache

ld.so.conf

ld.so.conf.d

lftp.conf

libao.conf

libgda-3.0

libpaper.d

locale.alias

localtime

logcheck

login.defs

logrotate.conf

logrotate.d

lsb-base

lsb-base-logging.sh

lsb-release

ltrace.conf

magic

magic.mime

mailcap

mailcap.order

manpath.config

mediaprm

menu-methods

mime.types

mke2fs.conf

modprobe.d

modules

modutils

mono

motd

motd.tail

mtab

nanorc

Net

netscsid.conf

network

NetworkManager

networks

nsswitch.conf

openalrc

openoffice

opt

pam.conf

pam.d

pango

papersize

passwd

passwd-

pcmcia

perl

pnm2ppa.conf

popularity-contest.conf

power

ppp

printcap

profile

protocols

purple

python

python2.5

rc0.d

rc1.d

rc2.d

rc3.d

rc4.d

rc5.d

rc6.d

rc.local

rcS.d

readahead

resolvconf

resolv.conf

rmt

rpc

samba

sane.d

scim

screenrc

scrollkeeper.conf

securetty

security

services

sgml

shadow

shadow-

shells

skel

sound

ssh

ssl

sudoers

sysctl.conf

syslog.conf

terminfo

timezone

ucf.conf

udev

uniconf.conf

updatedb.conf

update-notifier

usplash.conf

vim

w3m

wgetrc

wodim.conf

wpa_supplicant

wvdial.conf

X11

xdg

xml

zsh_command_not_found

acpi

adduser.conf

adjtime

aliases

alternatives

anacrontab

apm

apparmor

apparmor.d

apport

apt

at.deny

avahi

bash.bashrc

bash_completion

bash_completion.d

belocs

bindresvport.blacklist

blkid.tab

blkid.tab.old

bluetooth

bogofilter.cf

bonobo-activation

brlapi.key

brltty

brltty.conf

calendar

chatscripts

compizconfig

console-setup

console-tools

cron.d

cron.daily

cron.hourly

cron.monthly

crontab

cron.weekly

cups

dbus-1

debconf.conf

debian_version

default

defoma

deluser.conf

devfs

dhcp3

dictionaries-common

discover.conf

discover.conf-2.6

discover.d

dpkg

emacs

environment

esound

event.d

fdmount.conf

firefox

fonts

foomatic

fstab

fuse.conf

gai.conf

gamin

gconf

gdm

gnome

gnome-app-install

gnome-system-tools

gnome-vfs-2.0

gnome-vfs-mime-magic

groff

group

group-

grub.d

gshadow

gshadow-

gtk-2.0

hal

hdparm.conf

hesiod.conf

host.conf

hostname

hosts

hosts.allow

hosts.deny

hotplug

hp

init.d

initramfs-tools

inputrc

iproute2

issue

issue.net

java

kernel-img.conf

laptop-mode

ldap

ld.so.cache

ld.so.conf

ld.so.conf.d

lftp.conf

libao.conf

libgda-3.0

libpaper.d

locale.alias

localtime

logcheck

login.defs

logrotate.conf

logrotate.d

lsb-base

lsb-base-logging.sh

lsb-release

ltrace.conf

magic

magic.mime

mailcap

mailcap.order

manpath.config

mediaprm

menu-methods

mime.types

mke2fs.conf

modprobe.d

modules

modutils

mono

motd

motd.tail

mtab

nanorc

Net

netscsid.conf

network

NetworkManager

networks

nsswitch.conf

openalrc

openoffice

opt

pam.conf

pam.d

pango

papersize

passwd

passwd-

pcmcia

perl

pnm2ppa.conf

popularity-contest.conf

power

ppp

printcap

profile

protocols

purple

python

python2.5

rc0.d

rc1.d

rc2.d

rc3.d

rc4.d

rc5.d

rc6.d

rc.local

rcS.d

readahead

resolvconf

resolv.conf

rmt

rpc

samba

sane.d

scim

screenrc

scrollkeeper.conf

securetty

security

services

sgml

shadow

shadow-

shells

skel

sound

ssh

ssl

sudoers

sysctl.conf

syslog.conf

terminfo

timezone

ucf.conf

udev

uniconf.conf

updatedb.conf

update-notifier

usplash.conf

vim

w3m

wgetrc

wodim.conf

wpa_supplicant

wvdial.conf

X11

xdg

xml

zsh_command_not_found

5. Создаём в каталоге /tmp файл и копируем его на другую машину, также в каталог /tmp.

sergey@sergey-VirtualBox2:~$ cd /tmp

sergey@sergey-VirtualBox2:/tmp$ touch testfile

sergey@sergey-VirtualBox2:/tmp$ scp testfile user@10.98.27.1:/tmp

testfile 100% 0 0.0KB/s 00:00

6. Запускаем на другом компьютере программу xterm.

sergey@sergey-VirtualBox2:~$ ssh -X 10.98.27.1 xterm

7. Запускаем на разных компьютерах программы xcalc, xclock, xeyes, xload.

sergey@sergey-VirtualBox2:~$ ssh -X -f 10.98.27.1 xcalc

sergey@sergey-VirtualBox2:~$ ssh -X -f 10.98.27.1 xclock

sergey@sergey-VirtualBox2:~$ ssh -X -f 10.98.27.1 xeyes

sergey@sergey-VirtualBox2:~$ ssh -X -f 10.98.27.1 xload

8. Запустите на удаленном компьютере программу xflame при помощи ssh…

Программа отсутствует в данной операционной системе.

sergey@sergey-VirtualBox2:~$ ssh -X -f 10.98.27.1 xflame

sergey@sergey-VirtualBox2:~$ bash: xflame: команда не найдена

30