如何获得无所事事的公钥?

时间:2019-06-12 16:36:35

标签: ssh vagrant

所以问题是,当我通过ip并直接通过ssh命令执行ssh时,我能够使用密钥登录而无需提供任何密码,但是,当我尝试通过流浪汉使用ssh命令并使用主机名而不是ip要求输入密码

需要密码

    (venv) dans-test-mbp:public_network dantest$ vagrant ssh host1
vagrant@127.0.0.1's password: 
Last login: Wed Jun 12 16:33:35 2019 from 10.100.174.129
[vagrant@localhost ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:26:10:60 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic eth0
       valid_lft 84345sec preferred_lft 84345sec
    inet6 fe80::5054:ff:fe26:1060/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:9d:49:76 brd ff:ff:ff:ff:ff:ff
    inet 10.100.172.113/22 brd 10.100.175.255 scope global noprefixroute dynamic eth1
       valid_lft 343545sec preferred_lft 343545sec
    inet6 fe80::a00:27ff:fe9d:4976/64 scope link 
       valid_lft forever preferred_lft forever 

不需要密码

(venv) dans-test-mbp:public_network dantest$ ssh vagrant@10.100.172.113
Last login: Wed Jun 12 16:26:10 2019 from 10.0.2.2
[vagrant@localhost ~]$ exit
logout

我使用此配置来创建流浪者文件:

(venv) dans-test-mbp:public_network dantest$ cat Vagrantfile 
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|

  host_ips = [
    "host1",
    "host2",
    "host3",
    "host4"
  ]

  host_ips.each do |host_name|
      config.vm.define host_name do |host|
        host.vm.box = "centos/7"
        config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)"
        host.vm.synced_folder ".", "/home/vagrant/sync", disabled: true
        host.vm.provider "virtualbox" do |vb|
            # Customize the amount of memory on the VM:
            vb.memory = "4048"

            # Allow vm to send data via VPN
            vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
        end
      end
  end

end

所以,我遇到了问题,基本上,我用我的密钥覆盖了无业游民的发布密钥,因此无业游民无法进入它,但我可以。那么,现在的问题是我如何获得无所事事的酒吧钥匙?

1 个答案:

答案 0 :(得分:0)

您始终可以从以下位置拉下流浪者的默认公钥:https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub

在启动时,流浪者通常会用“安全”密钥替换该密钥。