この記事は約36分9秒で読むことができます。

ssh centos7 enable


[oracle@centos7 ~]$ pwd
/home/oracle
[oracle@centos7 ~]$ ll
合計 4
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Desktop
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Documents
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Downloads
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Music
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Pictures
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Public
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Templates
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Videos
drwxr-xr-x. 3 oracle docker   66 12月 23 17:12 docker
drwxrwxrwx. 4 oracle docker   32 12月 23 15:31 doclan
-rwxr-xr-x. 1 oracle docker 1299 12月 23 15:31 mkdir.sh
drwxr-xr-x. 2 oracle docker   24 12月 23 17:12 share
[oracle@centos7 ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa): 
Created directory '/home/oracle/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:uZjgdcQyJLlUXxdr1Z/bqnLmKQVWDwRF9LclCEUNDKo oracle@centos7
The key's randomart image is:
+---[RSA 2048]----+
|    .oo   =@@+.. |
|    oo o o o+=. .|
|   . .o =  .+oo =|
|    .  = .o.  .++|
|    . E S. .   .o|
|   . o + .  .  ..|
|    . o .  .   . |
|          o o..  |
|           *+.   |
+----[SHA256]-----+
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ ll -a
合計 40
drwx------. 21 oracle docker 4096 12月 27 20:43 .
drwxr-xr-x.  3 root   root     20 12月 23 14:28 ..
-rw-------.  1 oracle docker 1864 12月 23 15:45 .ICEauthority
-rw-------.  1 oracle docker 3392 12月 27 20:39 .bash_history
-rw-r--r--.  1 oracle docker   18  4月 11  2018 .bash_logout
-rw-r--r--.  1 oracle docker  193  4月 11  2018 .bash_profile
-rw-r--r--.  1 oracle docker  231  4月 11  2018 .bashrc
drwx------. 17 oracle docker 4096 12月 23 14:55 .cache
drwxr-xr-x. 19 oracle docker 4096 12月 24 00:02 .config
drwx------.  3 oracle docker   25 12月 23 14:41 .dbus
-rw-------.  1 oracle docker   16 12月 23 14:41 .esd_auth
drwx------.  3 oracle docker   18 12月 23 14:55 .gnome
drwx------.  3 oracle docker   19 12月 23 14:41 .local
drwxr-xr-x.  5 oracle docker   54 12月 23 14:48 .mozilla
drwx------.  3 oracle docker   19 12月 23 14:55 .pki
drwx------.  2 oracle docker   38 12月 27 20:43 .ssh
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Desktop
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Documents
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Downloads
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Music
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Pictures
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Public
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Templates
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Videos
drwxr-xr-x.  3 oracle docker   66 12月 23 17:12 docker
drwxrwxrwx.  4 oracle docker   32 12月 23 15:31 doclan
-rwxr-xr-x.  1 oracle docker 1299 12月 23 15:31 mkdir.sh
drwxr-xr-x.  2 oracle docker   24 12月 23 17:12 share
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ cd .ssh
[oracle@centos7 .ssh]$ pwd
/home/oracle/.ssh
[oracle@centos7 .ssh]$ ll
合計 8
-rw-------. 1 oracle docker 1766 12月 27 20:43 id_rsa
-rw-r--r--. 1 oracle docker  396 12月 27 20:43 id_rsa.pub
[oracle@centos7 .ssh]$ 

サーバー側


[oracle@centos7 ~]$ ip route
default via 192.168.100.1 dev wlp7s0 proto static metric 600 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.100.0/24 dev wlp7s0 proto kernel scope link src 192.168.100.107 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 
[oracle@centos7 ~]$ ll
合計 4
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Downloads
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x. 3 oracle docker   66 12月 23 15:21 docker
drwxrwxrwx. 4 oracle docker   32 12月 23 14:47 doclan
-rwxr-xr-x. 1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x. 2 oracle docker   42 12月 23 16:40 share
[oracle@centos7 ~]$ 

クライアント側


[oracle@centos7 .ssh]$ scp id_rsa.pub oracle@192.168.100.107:~
The authenticity of host '192.168.100.107 (192.168.100.107)' can't be established.
ECDSA key fingerprint is SHA256:lAUjRXceZduuHmiWxudjvCaspDoZb+klg+K1g40p/sI.
ECDSA key fingerprint is MD5:1d:f6:2b:f5:7e:8e:2d:b1:17:1d:b6:1b:b5:5d:c1:5f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.107' (ECDSA) to the list of known hosts.
oracle@192.168.100.107's password: 
id_rsa.pub                                                                                                    100%  396    43.1KB/s   00:00    
[oracle@centos7 .ssh]$ 

サーバー側


[oracle@centos7 ~]$ ll
合計 8
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Downloads
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x. 3 oracle docker   66 12月 23 15:21 docker
drwxrwxrwx. 4 oracle docker   32 12月 23 14:47 doclan
-rw-r--r--. 1 oracle docker  396 12月 28 20:07 id_rsa.pub
-rwxr-xr-x. 1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x. 2 oracle docker   42 12月 23 16:40 share
[oracle@centos7 ~]$ 


[oracle@centos7 .ssh]$ ip route
default via 192.168.100.1 dev wlp2s0 proto static metric 600 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.100.0/24 dev wlp2s0 proto kernel scope link src 192.168.100.108 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 
--ホスト名一緒やとぜんぜんわかね
[oracle@centos7 .ssh]$ ssh oracle@192.168.100.107
oracle@192.168.100.107's password: 
Last login: Fri Dec 28 20:22:43 2018 from 192.168.100.108
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ cd ~ && cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRelZ3eydODQTdFCzCZGd5DlH0SBUkWxkTodK30b1pk37D9WDsxDFF1iOTcFVZFsYlQzMUpn1R1fM2Dhjcu7WrBmwhxsfB09bpl+HK/ZlQNZgfysEnR1mOfilai30LioV84+VFKNdiQUP+4iG6pzXMNJaqyWytLFr9gYqWRgp0znakGB187XdOEhTkNWXcP4gQsHbrB02SSTPTn8Ern+bYAdzHfNEMm8yezJFOycF0vkWQbkYqg+uf5Ry/Cy3GB7Sf6H7q78vVR+6ambU0HDhYPY3dzQ02WQeab5clMy4A5zX8fDVqfV/mncNT1GxG1e8XInl4kHxqjWStm24S8sDr oracle@centos7
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ mkdir ~/.ssh
[oracle@centos7 ~]$ ll -at
合計 48
drwx------. 21 oracle docker 4096 12月 28 20:31 .
drwxr-xr-x.  2 oracle docker    6 12月 28 20:31 .ssh
-rw-------.  1 oracle docker 4925 12月 28 20:23 .bash_history
-rw-r--r--.  1 oracle docker  396 12月 28 20:07 id_rsa.pub
drwxr-xr-x. 19 oracle docker 4096 12月 23 21:56 .config
drwxr-xr-x.  2 oracle docker   42 12月 23 16:40 share
drwxr-xr-x.  3 oracle docker   66 12月 23 15:21 docker
-rw-------.  1 oracle docker 1554 12月 23 15:16 .ICEauthority
drwxrwxrwx.  4 oracle docker   32 12月 23 14:47 doclan
-rwxr-xr-x.  1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Downloads
drwx------.  3 oracle docker   18 12月 23 10:53 .gnome
drwx------.  3 oracle docker   19 12月 23 10:53 .pki
drwx------. 17 oracle docker 4096 12月 23 10:53 .cache
drwxr-xr-x.  5 oracle docker   54 12月 23 10:45 .mozilla
-rw-------.  1 oracle docker   16 12月 23 10:44 .esd_auth
drwx------.  3 oracle docker   19 12月 23 10:44 .local
drwx------.  3 oracle docker   25 12月 23 10:44 .dbus
drwxr-xr-x.  3 root   root     20 12月 23 10:39 ..
-rw-r--r--.  1 oracle docker   18  4月 11  2018 .bash_logout
-rw-r--r--.  1 oracle docker  193  4月 11  2018 .bash_profile
-rw-r--r--.  1 oracle docker  231  4月 11  2018 .bashrc
[oracle@centos7 ~]$ chmod 700 .ssh
[oracle@centos7 ~]$ ll -at
合計 48
drwx------. 21 oracle docker 4096 12月 28 20:31 .
drwx------.  2 oracle docker    6 12月 28 20:31 .ssh
-rw-------.  1 oracle docker 4925 12月 28 20:23 .bash_history
-rw-r--r--.  1 oracle docker  396 12月 28 20:07 id_rsa.pub
drwxr-xr-x. 19 oracle docker 4096 12月 23 21:56 .config
drwxr-xr-x.  2 oracle docker   42 12月 23 16:40 share
drwxr-xr-x.  3 oracle docker   66 12月 23 15:21 docker
-rw-------.  1 oracle docker 1554 12月 23 15:16 .ICEauthority
drwxrwxrwx.  4 oracle docker   32 12月 23 14:47 doclan
-rwxr-xr-x.  1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Downloads
drwx------.  3 oracle docker   18 12月 23 10:53 .gnome
drwx------.  3 oracle docker   19 12月 23 10:53 .pki
drwx------. 17 oracle docker 4096 12月 23 10:53 .cache
drwxr-xr-x.  5 oracle docker   54 12月 23 10:45 .mozilla
-rw-------.  1 oracle docker   16 12月 23 10:44 .esd_auth
drwx------.  3 oracle docker   19 12月 23 10:44 .local
drwx------.  3 oracle docker   25 12月 23 10:44 .dbus
drwxr-xr-x.  3 root   root     20 12月 23 10:39 ..
-rw-r--r--.  1 oracle docker   18  4月 11  2018 .bash_logout
-rw-r--r--.  1 oracle docker  193  4月 11  2018 .bash_profile
-rw-r--r--.  1 oracle docker  231  4月 11  2018 .bashrc
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ cd .ssh
[oracle@centos7 .ssh]$ ll
合計 0
[oracle@centos7 .ssh]$ touch ~/.ssh/authorized_keys
[oracle@centos7 .ssh]$ ll
合計 0
-rw-r--r--. 1 oracle docker 0 12月 28 20:35 authorized_keys
[oracle@centos7 .ssh]$ chmod 600 ~/.ssh/authorized_keys
[oracle@centos7 .ssh]$ ll
合計 0
-rw-------. 1 oracle docker 0 12月 28 20:35 authorized_keys
[oracle@centos7 .ssh]$ 


[oracle@centos7 .ssh]$ ログアウト
Connection to 192.168.100.107 closed.
[oracle@centos7 .ssh]$ ip route
default via 192.168.100.1 dev wlp2s0 proto static metric 600 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.100.0/24 dev wlp2s0 proto kernel scope link src 192.168.100.108 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 
[oracle@centos7 .ssh]$ 


[oracle@centos7 .ssh]$ ll
合計 12
-rw-------. 1 oracle docker 1766 12月 27 20:43 id_rsa
-rw-r--r--. 1 oracle docker  396 12月 27 20:43 id_rsa.pub
-rw-r--r--. 1 oracle docker  177 12月 28 20:07 known_hosts
[oracle@centos7 .ssh]$ cat known_hosts
192.168.100.107 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCVDRp3jReHwU4wAxBVo4Aat+UHtKLl4VVpKA3x8k+nTygk4odsn01Zrj8PDzSGd1zGT1DTXFZqYF2C+kYzkd3s=
[oracle@centos7 .ssh]$ 


[oracle@centos7 .ssh]$ ssh oracle@192.168.100.107
oracle@192.168.100.107's password: 
Last login: Fri Dec 28 20:23:22 2018 from 192.168.100.108
[oracle@centos7 ~]$ ifconfig
docker0: flags=4163  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:e6ff:fe51:a6d6  prefixlen 64  scopeid 0x20 	 	 	 	
        ether 02:42:e6:51:a6:d6  txqueuelen 0  (Ethernet)
        RX packets 72756  bytes 34705340 (33.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 133133  bytes 158851749 (151.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp25s0: flags=4099  mtu 1500
        ether fc:61:98:4f:19:5f  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8138  bytes 614263 (599.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8138  bytes 614263 (599.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth24ff817: flags=4163  mtu 1500
        inet6 fe80::707d:b1ff:fe06:274b  prefixlen 64  scopeid 0x20 	 	 	 	
        ether 72:7d:b1:06:27:4b  txqueuelen 0  (Ethernet)
        RX packets 24877  bytes 18606254 (17.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 39457  bytes 38601382 (36.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:78:5b:56  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp7s0: flags=4163  mtu 1500
        inet 192.168.100.107  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 2001:268:c031:29e9:98e7:f562:4ec4:3  prefixlen 128  scopeid 0x0
        inet6 fe80::4bff:9d03:eef7:9a10  prefixlen 64  scopeid 0x20 	 	 	 	
        inet6 2001:268:c031:29e9:1a2b:1bda:f699:4627  prefixlen 64  scopeid 0x0
        ether 74:e5:0b:ba:d1:ac  txqueuelen 1000  (Ethernet)
        RX packets 917681  bytes 975680107 (930.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 599486  bytes 167522088 (159.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[oracle@centos7 ~]$ 


[oracle@centos7 .ssh]$ ll
合計 12
-rw-------. 1 oracle docker 1766 12月 27 20:43 id_rsa
-rw-r--r--. 1 oracle docker  396 12月 27 20:43 id_rsa.pub
-rw-r--r--. 1 oracle docker  177 12月 28 20:07 known_hosts
[oracle@centos7 .ssh]$ ssh -i id_rsa.pub oracle@192.168.100.107
oracle@192.168.100.107's password: 
Last login: Fri Dec 28 20:38:26 2018 from 192.168.100.108
[oracle@centos7 ~]$ ログアウト
Connection to 192.168.100.107 closed.

Leave a Reply

Your email address will not be published. Required fields are marked *