Подготовка виртуальных машин
Имеется 2 виртуальные машины.
Необходимо сделать возможным доступ с одной машины на другую по SSH без авторизации по паролю.
[root@server1 ~]# vi /etc/hosts
############################################
## eth0 - Internal
192.168.1.21 server1.localdomain server1
192.168.1.22 server2.localdomain server2
############################################
===============================
[root@server1 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:
7d:4e:86:33:bd:d9:f9:18:0d:9e:a6:b4:5f:24:2e:1d [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| |
| . o |
| S = = E .|
| B B O |
| * X o|
| . = = |
| o.o .|
+-----------------+
Вариант 1
[root@server1 ~]# ssh-copy-id server2
The authenticity of host 'server2 (192.168.1.22)' can't be established.
RSA key fingerprint is 0d:b6:67:4c:37:94:d8:b4:91:48:33:fd:e5:74:65:5a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'server2,192.168.1.22' (RSA) to the list of known hosts.
root@server2's password:
Now try logging into the machine, with "ssh 'server2'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[root@server1 ~]# ssh server2 cat .ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA10NjEpmtJ5/vyku5/pQJ8y1oTsd2xZ4qK3N1pNwNpeBQKh2yWGHL/zG02o6mf9HLXk/NMbw8jW1XixyyD1F9vCObMEAf1cDC68CKEYH1RpGTI82eaviIW61VcTf2FT70QDfUX7ssQ1gbGGRLIkM+YaLanMs/xAwb/WvmPgay/5Zaa0DxqPg8NcnP1lI7bHJDDj1w3kves2WvqNu4QWvtNwLae7uDU4XqV/SwRhL9dsvSCBrxgz8MP/bW8mNlJ7k+NHv9zcvffjgoYyyUyGArqSG5jpPwe4k9Kc2OLtZgQLxck0w7YleqEwQ6kDm2nomIE/wB052D6n6ZVlNYvpSvGQ== [email protected]
[root@server1 ~]# ssh server2
[root@server2 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
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:
04:ae:24:4b:03:55:f0:44:69:89:fc:ec:76:b8:01:d3 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|.oo=+o. |
| .oo+. . |
| +=o . . |
| .o=E. . |
| .+.. S |
| = . |
| . + |
| . |
| |
+-----------------+
[root@server2 ~]# ssh-copy-id server1
root@server1's password:
Now try logging into the machine, with "ssh 'server1'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
=======
[root@server1 ~]# scp /etc/hosts server2:/etc/
==================================================
### UPDATE
[root@server1 ~]# yum update -y && ssh server2 yum update -y
### NTP
[root@server1 ~]# yum install -y ntp && ssh server2 yum install -y ntp
[root@server1 ~]# chkconfig --level 345 ntpd on && ssh server2 chkconfig --level 345 ntpd on
[root@server1 ~]# service ntpd restart && ssh server2 service ntpd restart
[root@server1 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*ntp1.regnets.ru 212.20.50.208 2 u 2 64 1 53.898 6.835 0.990
vsit.krsn.ru 148.6.0.1 3 u 1 64 1 63.772 1.604 0.360
ground.corbina. 46.46.152.214 2 u 2 64 1 2.413 4.255 1.196
95.140.150.140 31.28.161.68 2 u 1 64 1 16.920 4.085 4.667
Материалы:
http://wiki.val.bmstu.ru/doku.php?id=%D1%81%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5_%D0%BE%D1%82%D0%BA%D0%B0%D0%B7%D0%BE%D1%83%D1%81%D1%82%D0%BE%D0%B9%D1%87%D0%B8%D0%B2%D1%8B%D1%85_unix_%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D0%B9