Authentication failure. Retrying - 徹底解決vagrant up時警告

      網友投稿 1274 2025-04-01

      碰到的問題

      使用vagrant啟動虛擬機時,出現如下警告:

      vagrant up?default:?Warning:?Authentication failure. retrying...

      原因分析

      授權失敗主要原因:

      虛擬機獲取不到物理機的公鑰(有疑問的小伙伴,建議先了解一下SSH)

      解決方案

      將公鑰復制到虛擬機vagrant用戶家目錄下的authorized_keys文件中

      Vagrantfile中指定物理機當前用戶的私鑰路徑

      步驟一、確認物理機中已經生成了公鑰和私鑰

      以windows系統為例,查看當前登錄用戶的文件夾下是否包含.ssh文件夾,以及.ssh文件夾下是否包含id_rsa(私鑰)、id_rsa.pub(公鑰)兩個文件

      .ssh文件夾文件如下:

      注意:必須打開 【顯示隱藏的文件、文件夾或驅動器】才能看到.ssh文件夾

      如果已經包含id_rsa(私鑰)、id_rsa.pub(公鑰)兩個文件則可跳過步驟一。如果沒有兩個文件則繼續往下看

      生成公鑰和私鑰有多種方法,我們使用最常用的辦法。開發者一般都會安裝git。直接使用git bash生成一下就好了

      一路回車,完成后,記住下面的地址

      這兩個文件的含是:首先,他們是1對的,兩者缺1不可,id_rsa 是私鑰,id_rsa.pub是公鑰

      步驟二、將公鑰復制到authorized_keys文件中

      小伙伴可能奇怪,vagrant都報錯了,怎么還能進入虛擬機?沒錯!其實此時虛擬機已經啟動完畢了,只不過此時不能接受vagrant的命令,也無法設置共享目錄。

      一般來說默認的用戶名是vagrant,密碼也是vagrant。

      查看是否有authorized_keys文件

      [vagrant@localhost .ssh]$ pwd

      /home/vagrant/.ssh

      [vagrant@localhost .ssh]$ ls -al

      total 8

      drwx------ 2 vagrant root 28 Jul 26 2016 .

      drwx------. 8 vagrant vagrant 4096 Nov 6 11:02 ..

      -rw------- 1 vagrant vagrant 786 Jul 26 2016 authorized_keys

      [vagrant@localhost .ssh]$

      如果authorized_keys文件不存在,則自己手動創建一下。

      注意authorized_keys 文件的權限是600,所有者是vagrant,所屬組也是vagrant

      [vagrant@localhost .ssh]$ touch authorized_keys

      [vagrant@localhost .ssh]$ chmod 600 authorized_keys

      如果已經存在authorized_keys文件,復制物理機公鑰文件id_rsa.pub的內容,粘貼到authorized_keys文件中。每個公鑰只占一行

      注意:公鑰內容只占一行

      例如我的authorized_keys文件中有兩個公鑰

      [vagrant@localhost .ssh]$ vim authorized_keys

      1 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDlo4N35+9OM2UCAC82E4RtiqROZU/jI6bgg76QAA56cGdLwk4CNZzbn309nNRtO7tyBtWCyFx2AOn3Hd8hIFWiokMgxlf3eSjowT9dZqmbhGrYzAkPq r63rpHUX7M4FVjMLtoREqrGbBQZ7uZItViKeXXXl7bsGOUserLchzi+p3PJgjmw5j6ea+Kj2P7EThvcevoEPLcwGyckCTEiYo8nJ21K5bkmKCi2F8kaaJ9zbIeJ/2woayUkoZeufNo3A/gZx2bvHYAiFT 4RYLDwjrspq7pQS5Cs83YUGvolPKQfCrJRH3N+sNaeHx1NzEULMvQNxgEsFIVpi5k7OBIf4BY/ vagrant

      2 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCov9Z/3qVWXkxLS6koRWxNu9lEt+e0+/6M+XCtDx7qWiCCZovNSCbKAHO3gwCV3myIyoiP/9bv2d0Sw18d/5BMYHWT4l85IZdF87no0Euu8Yt1w4BEU rCbL0jrDXHlVBhMyCeETr7BKDlM56meiNMo/PvNuN3qcp6tukLUXgrFRQ24hgg1mMvqQ0Km5UHYnHr+Vygc3udEVEEG5Px+04y6ap8gRZg7tKVgckdXZ7+1rNJtTXqR81uXXXbyown4eoccqsUTOK3iUs 2GdFwH/t3unbCSLu13UKDcLGG6hKG/x4aA1itIl3NdbzODgbte8UGXlifomayG+PTaf1tvb+n/ dc@GZ-Design003

      步驟三、在物理機的Vagrantfile中添加以下內容

      config.ssh.private_key_path = "C:/Users/dc/.ssh/id_rsa"

      config.ssh.forward_agent = true

      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|

      config.vm.box = "web"

      config.ssh.private_key_path = "C:/Users/dc/.ssh/id_rsa"

      config.ssh.forward_agent = true

      # config.winnfsd.logging="on"

      # config.winnfsd.uid=1

      # config.winnfsd.gid=1

      # config.vm.synced_folder "./","/vagrant",type:"nfs"

      config.vm.define :web do |web|

      web.vm.provider "virtualbox" do |v|

      v.customize ["modifyvm", :id, "--name", "web", "--memory", "2048", "--cpus","2"]

      end

      web.vm.box = "web"

      web.vm.hostname = "web"

      Authentication failure. Retrying - 徹底解決vagrant up時警告

      web.vm.synced_folder "./","/vagrant"

      # web.vm.network:private_network, ip: "192.168.33.11"

      web.vm.network "public_network"

      end

      config.vm.define :php do |php|

      php.vm.provider "virtualbox" do |v|

      v.customize ["modifyvm", :id, "--name", "php", "--memory", "512"]

      end

      php.vm.box = "php"

      php.vm.network:private_network, ip: "192.168.33.10"

      # php.vm.network "public_network", ip: "192.168.33.10"

      php.vm.synced_folder "./","/vagrant",type:"nfs"

      php.winnfsd.logging="on"

      php.winnfsd.uid=1

      php.winnfsd.gid=1

      php.vm.synced_folder "./","/vagrant"

      end

      config.vm.define :swoole do |swoole|

      swoole.vm.provider "virtualbox" do |v|

      v.customize ["modifyvm", :id, "--name", "swoole", "--memory", "512"]

      end

      swoole.vm.box = "swoole"

      # swoole.vm.network:private_network, ip: "192.168.33.12"

      swoole.vm.network "public_network", ip: "192.168.33.12"

      # swoole.vm.synced_folder "./","/vagrant",type:"nfs"

      swoole.vm.synced_folder "./","/vagrant"

      end

      config.vm.define :master do |master|

      master.vm.provider "virtualbox" do |v|

      v.customize ["modifyvm", :id, "--name", "master", "--memory", "512"]

      end

      master.vm.box = "master"

      master.vm.network "public_network"

      master.vm.synced_folder "./","/vagrant"

      end

      config.vm.define :slave do |slave|

      slave.vm.provider "virtualbox" do |v|

      v.customize ["modifyvm", :id, "--name", "slave", "--memory", "512"]

      end

      slave.vm.box = "slave"

      slave.vm.network "public_network"

      slave.vm.synced_folder "./","/vagrant"

      end

      end

      # The most common configuration options are documented and commented below.

      # For a complete reference, please see the online documentation at

      # https://docs.vagrantup.com.

      # Every Vagrant development environment requires a box. You can search for

      # boxes at https://atlas.hashicorp.com/search.

      # Disable automatic box update checking. If you disable this, then

      # boxes will only be checked for updates when the user runs

      # `vagrant box outdated`. This is not recommended.

      # config.vm.box_check_update = false

      # Create a forwarded port mapping which allows access to a specific port

      # within the machine from a port on the host machine. In the example below,

      # accessing "localhost:8080" will access port 80 on the guest machine.

      # config.vm.network "forwarded_port", guest: 80, host: 8080

      # Create a private network, which allows host-only access to the machine

      # using a specific IP.

      # config.vm.network "private_network", ip: "192.168.33.10"

      # Create a public network, which generally matched to bridged network.

      # Bridged networks make the machine appear as another physical device on

      # your network.

      # config.vm.network "public_network"

      # Share an additional folder to the guest VM. The first argument is

      # the path on the host to the actual folder. The second argument is

      # the path on the guest to mount the folder. And the optional third

      # argument is a set of non-required options.

      # config.vm.synced_folder "../data", "/vagrant_data"

      # Provider-specific configuration so you can fine-tune various

      # backing providers for Vagrant. These expose provider-specific options.

      # Example for VirtualBox:

      #

      # config.vm.provider "virtualbox" do |vb|

      # # Display the VirtualBox GUI when booting the machine

      # vb.gui = true

      #

      # # Customize the amount of memory on the VM:

      # vb.memory = "1024"

      # end

      #

      # View the documentation for the provider you are using for more

      # information on available options.

      # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies

      # such as FTP and Heroku are also available. See the documentation at

      # https://docs.vagrantup.com/v2/push/atlas.html for more information.

      # config.push.define "atlas" do |push|

      # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"

      # end

      # Enable provisioning with a shell script. Additional provisioners such as

      # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the

      # documentation for more information about their specific syntax and use.

      # config.vm.provision "shell", inline: <<-SHELL

      # sudo apt-get update

      # sudo apt-get install -y apache2

      # SHELL

      步驟四、重啟虛擬機

      在物理機的命令行重啟虛擬機

      vagrant?reload XXXX

      轉載:https://segmentfault.com/a/1190000011925921

      Python 虛擬化

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:小程序里的文件怎么轉出來
      下一篇:為什么打印機說是脫機呢(為什么打印機處于脫機)
      相關文章
      亚洲国产精品国自产拍电影| 亚洲Aⅴ无码专区在线观看q| 亚洲成a人片在线看| 亚洲国产成人久久综合一| 亚洲国产美女精品久久久久∴| 久久精品国产亚洲Aⅴ香蕉| 亚洲裸男gv网站| 亚洲精品NV久久久久久久久久| 亚洲国产成人久久综合野外| 日韩精品亚洲专区在线观看| 亚洲A∨午夜成人片精品网站| 国产亚洲日韩在线a不卡| 四虎精品亚洲一区二区三区| 婷婷综合缴情亚洲狠狠尤物| 国产大陆亚洲精品国产| 国产成人亚洲午夜电影| 国产精品亚洲а∨无码播放麻豆 | 亚洲AV无码成人精品区在线观看| 国产精品亚洲A∨天堂不卡 | 亚洲国产无套无码av电影| 亚洲成AV人片在线播放无码| 亚洲av中文无码乱人伦在线咪咕 | 亚洲av无码专区青青草原| 亚洲精品无码你懂的| 人人狠狠综合久久亚洲| 亚洲Av无码乱码在线观看性色| 国产精品亚洲不卡一区二区三区| 亚洲精品午夜无码专区| 久久夜色精品国产嚕嚕亚洲av| 亚洲视频国产视频| 亚洲av无码电影网| 亚洲成a∨人片在无码2023| 亚洲AV无码一区二区三区国产 | 亚洲情A成黄在线观看动漫软件| 亚洲va在线va天堂成人| 亚洲成AV人片高潮喷水| jlzzjlzz亚洲乱熟在线播放| 亚洲AV无码精品色午夜在线观看 | 亚洲国产成人a精品不卡在线| 久久亚洲国产成人精品无码区| 亚洲va无码手机在线电影|