|
|
|
@ -1,6 +1,138 @@
|
|
|
|
|
# Решения
|
|
|
|
|
|
|
|
|
|
### 1.
|
|
|
|
|
Скачайте дистрибутив debian debian-11.4.0-amd64-netinst.iso c http://mirror.corbina.net/debian-cd/current/amd64/iso-cd/.
|
|
|
|
|
Рассчитайте хэш sha256 командой sha256sum для дистрибутива debian и проверьте целостность данных, сравнив значение
|
|
|
|
|
с значением в файле SHA256SUMS.
|
|
|
|
|
```
|
|
|
|
|
$ sha256sum debian-11.4.0-amd64-netinst.iso
|
|
|
|
|
d490a35d36030592839f24e468a5b818c919943967012037d6ab3d65d030ef7f debian-11.4.0-amd64-netinst.iso
|
|
|
|
|
$ head -n1 SHA256SUMS
|
|
|
|
|
d490a35d36030592839f24e468a5b818c919943967012037d6ab3d65d030ef7f debian-11.4.0-amd64-netinst.iso
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 2.
|
|
|
|
|
Зашифруйте и расшифруйте данные с помощью openssl enc. Используйте команды:
|
|
|
|
|
```
|
|
|
|
|
$ cat helloworld.txt
|
|
|
|
|
Hello world!
|
|
|
|
|
$ openssl enc -in helloworld.txt -out encrypted.data -e -aes256 -k password
|
|
|
|
|
$ cat encrypted.data
|
|
|
|
|
Salted__I<EFBFBD><EFBFBD><EFBFBD>f<EFBFBD><EFBFBD><EFBFBD>0<EFBFBD>Z558<EFBFBD>+<2B>߮
|
|
|
|
|
3<EFBFBD>5<EFBFBD><EFBFBD><EFBFBD>Urq<EFBFBD><EFBFBD>T<EFBFBD>
|
|
|
|
|
$ openssl enc -d -aes-256-cbc -in encrypted.data -out un_encrypted.data
|
|
|
|
|
$ cat un_encrypted.data
|
|
|
|
|
Hello world!
|
|
|
|
|
2022
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 3.
|
|
|
|
|
Зашифруйте и расшифруйте данные с помощью gpg. Используйте команды:
|
|
|
|
|
```
|
|
|
|
|
$ cat helloworld.txt
|
|
|
|
|
Hello world!
|
|
|
|
|
$ gpg --output encrypted.data --symmetric --cipher-algo AES256 un_encrypted.data
|
|
|
|
|
$ cat encrypted_with_gpg.data
|
|
|
|
|
<EFBFBD> <20><>Ȥ<EFBFBD><C8A4>P<EFBFBD><50>
|
|
|
|
|
P.W<>{<7B>Vu]x|M<>C<EFBFBD><43><EFBFBD><EFBFBD>l<EFBFBD>@<40>s<EFBFBD>k<EFBFBD><6B>c<EFBFBD>N<EFBFBD>}<7D><>|<7C>Yn<59><6E><EFBFBD><EFBFBD><EFBFBD>a}<7D><><EFBFBD>d!I<><49>_E<5F><45><EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><78>I<EFBFBD><49><EFBFBD><EFBFBD>
|
|
|
|
|
$ gpg --output un_encrypted_with_gpg.data --decrypt encrypted_with_gpg.data
|
|
|
|
|
$ $ cat un_encrypted_with_gpg.data
|
|
|
|
|
Hello world!
|
|
|
|
|
2022
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 4.
|
|
|
|
|
Сгенерируйте ed25519 пару ключей `ssh-keygen -o -a 100 -t ed25519`. Перейдите в `~/.ssh/` и проверьте, появилась ли пара SSH-ключей. Настройте возможность беспарольного входа в систему по ssh, добавить содержимое публичного ключа (.pub) в `authorized_keys` в той же директории (создайте файл, если его не существует).
|
|
|
|
|
```
|
|
|
|
|
$ ssh-keygen -o -a 100 -t ed25519
|
|
|
|
|
Generating public/private ed25519 key pair.
|
|
|
|
|
Enter file in which to save the key (/home/stud/.ssh/id_ed25519): /home/stud/.ssh/4task_id_ed25519
|
|
|
|
|
Enter passphrase (empty for no passphrase):
|
|
|
|
|
Enter same passphrase again:
|
|
|
|
|
Your identification has been saved in /home/stud/.ssh/4task_id_ed25519
|
|
|
|
|
Your public key has been saved in /home/stud/.ssh/4task_id_ed25519.pub
|
|
|
|
|
The key fingerprint is:
|
|
|
|
|
SHA256:qzxgVYtYie5em9GC7q8mMX26LNEwEfEgsalIY0v8dEA stud@stud15
|
|
|
|
|
The key's randomart image is:
|
|
|
|
|
+--[ED25519 256]--+
|
|
|
|
|
|o.=E . . |
|
|
|
|
|
|.+.oo o . |
|
|
|
|
|
|o* +.+ o . |
|
|
|
|
|
|* B + o . |
|
|
|
|
|
|o. B o .S |
|
|
|
|
|
| + B = .. |
|
|
|
|
|
| B = =. |
|
|
|
|
|
| o.=.+. |
|
|
|
|
|
| ==++. |
|
|
|
|
|
+----[SHA256]-----+
|
|
|
|
|
$ ls
|
|
|
|
|
4task_id_ed25519 4task_id_ed25519.pub authorized_keys id_rsa id_rsa.pub known_hosts
|
|
|
|
|
$ cat 4task_id_ed25519.pub >> authorized_keys
|
|
|
|
|
$ tail -n 1 authorized_keys
|
|
|
|
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ2O9POMD+URq+UkWUNgU475wvxmhTVPRkjAHq8DDLye stud@stud15
|
|
|
|
|
$ ssh localhost -i /home/stud/.ssh/4task_id_ed25519
|
|
|
|
|
Linux stud15 5.10.0-16-amd64 #1 SMP Debian 5.10.127-1 (2022-06-30) x86_64
|
|
|
|
|
|
|
|
|
|
The programs included with the Debian GNU/Linux system are free software;
|
|
|
|
|
the exact distribution terms for each program are described in the
|
|
|
|
|
individual files in /usr/share/doc/*/copyright.
|
|
|
|
|
|
|
|
|
|
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
|
|
|
|
|
permitted by applicable law.
|
|
|
|
|
Last login: Wed Sep 7 20:02:39 2022 from 87.229.245.190
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 5.
|
|
|
|
|
Используйте `ssh-copy-id имя-удаленной-машины`, чтобы скопировать ваш ssh-ключ на сервер. Перед установкой попробуйте команду
|
|
|
|
|
в тестовом режиме с ключём `-n`.
|
|
|
|
|
```
|
|
|
|
|
$ ssh-copy-id -i 4task_id_ed25519 stud@193.32.63.185
|
|
|
|
|
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "4task_id_ed25519.pub"
|
|
|
|
|
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
|
|
|
|
|
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
|
|
|
|
|
|
|
|
|
|
Number of key(s) added: 1
|
|
|
|
|
|
|
|
|
|
Now try logging into the machine, with: "ssh 'stud@193.32.63.185'"
|
|
|
|
|
and check to make sure that only the key(s) you wanted were added.
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 6.
|
|
|
|
|
Отредактируйте `.ssh/config` на локальной машине, чтобы запись выглядела следующим образом
|
|
|
|
|
```
|
|
|
|
|
$ cat config
|
|
|
|
|
Host remote
|
|
|
|
|
User stud
|
|
|
|
|
HostName 193.32.63.185
|
|
|
|
|
IdentityFile ~/.ssh/4task_id_ed25519
|
|
|
|
|
$ ssh remote
|
|
|
|
|
Linux stud15 5.10.0-16-amd64 #1 SMP Debian 5.10.127-1 (2022-06-30) x86_64
|
|
|
|
|
|
|
|
|
|
The programs included with the Debian GNU/Linux system are free software;
|
|
|
|
|
the exact distribution terms for each program are described in the
|
|
|
|
|
individual files in /usr/share/doc/*/copyright.
|
|
|
|
|
|
|
|
|
|
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
|
|
|
|
|
permitted by applicable law.
|
|
|
|
|
Last login: Wed Sep 7 20:17:07 2022 from ::1
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 7.
|
|
|
|
|
Отредактируйте конфигурацию вашего SSH-сервера, выполнив `sudo vi /etc/ssh/sshd_config`. Отключите проверку по паролю, отредактировав значение `PasswordAuthentication`. Отключите вход с правами суперпользователя, отредактировав значение `PermitRootLogin`. Перезапустите службу ssh с помощью `sudo systemctl restart sshd`.
|
|
|
|
|
|
|
|
|
|
Попробуйте подключиться ещё раз. Попробуйте подключиться ещё раз по паролю (добавьте флаг -o PubkeyAuthentication=no к ssh команде).
|
|
|
|
|
```
|
|
|
|
|
$ cat /etc/ssh/sshd_config | grep -e '^\(PasswordAuthentication\|PermitRootLogin\)' |
|
|
|
|
|
PermitRootLogin prohibit-password
|
|
|
|
|
PasswordAuthentication no
|
|
|
|
|
$ sudo systemctl restart sshd
|
|
|
|
|
$ ssh remote -o PubkeyAuthentication=no
|
|
|
|
|
stud@10.160.179.25: Permission denied (publickey).
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
8.
|
|
|
|
|
### 8.
|
|
|
|
|
Сгенерируйте сертификат x.509 и ключ с помощью openssl. Посмотрите содержимое сертификата командой `openssl x509`.
|
|
|
|
|
```
|
|
|
|
|
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -nodes -days 365 -subj '/C=RU/ST=SamaraRegion/L=Samara/O=MyOffice/OU=SamaraDep/CN=myoffice.ru/'
|
|
|
|
|
openssl x509 -in cert.pem -noout -text
|
|
|
|
|