LoginSignup
1
0

More than 5 years have passed since last update.

SSH通信、公開鍵認証方式とパスワード認証方式

Last updated at Posted at 2019-01-23

公開鍵認証方式とパスワード認証方式の違い

  • 公開鍵認証方式:パスワードを求められずそのままアクセスできる
  • パスワード認証方式:パスワードを求められる

VMの作成

  • 前提
    • VagrantでVirtual Box上にVMを立てた
Vagrantfile

Vagrant.configure(2) do |config|
  config.vm.define "controller" do |node|
        node.vm.box = "bento/centos-7.2"
        node.vm.hostname = "controller"
        node.vm.network :private_network, ip: "192.168.100.10"
        node.vm.network :forwarded_port, id: "ssh", guest: 22, host: 2250        
  end
end

接続方式の差異を確認

作成したVMにsshアクセス

パスワード認証方式
$ ssh root@localhost -p 2250
root@localhost's password:

パスワードを求められる。
一方keypairを取得してVMに送りつけると

公開鍵認証方式
$ ssh-keygen -t rsa
・
・
[何も入力せずにEnter -> Pairが生成される]
・
・

$ ssh-copy-id root@localhost -p 2250
・
・
root@localhost's password:

Number of key(s) added:
・
・


$ ssh root@localhost -p 2250
Last login: Wed Jan 23 05:59:25 2019 from 10.0.2.2
[root@controller ~]#

鍵を送りつけるときにパスワードは求められるものの、その後はVMにssh接続する際にパスワードを求められなくなった。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0