2017-08-09 129 views
0

我有vagrant運行scotchbox。我最近嘗試將id_rsa.pub添加到/vagrant/home/.ssh,希望能夠在不輸入密碼的情況下進行ssh操作。一旦我做到了,它的行爲是一樣的,所以我把它刪除了。現在我正在給配置添加另一個站點,現在我無法做無極限配置,因爲它給了我以下錯誤。vagrant provision ssh問題

SSH身份驗證失敗!這通常是由 訪客虛擬機上未正確設置的SSH用戶的公鑰/私鑰對導致的。請驗證訪客虛擬機是否安裝了合適的公鑰 ,並且Vagrant的私鑰路徑也正確設置爲 。

下面是我從流浪漢的ssh-配置

HostName 127.0.0.1 
    User vagrant 
    Port 2222 
    UserKnownHostsFile /dev/null 
    StrictHostKeyChecking no 
    PasswordAuthentication no 
    IdentityFile "/Users/username/.vagrant.d/boxes/scotch-VAGRANTSLASH-box/3.0/virtualbox/vagrant_private_key" 
    IdentitiesOnly yes 
    LogLevel FATAL 

這裏是我的無業遊民文件中獲取。

Vagrant.configure("2") do |config| 

    config.vm.box = "scotch/box" 
    config.vm.network "private_network", ip: "192.168.10.10" 
    config.vm.hostname = "scotchbox" 
    config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=775", "fmode=664"] 


config.vm.provider "virtualbox" do |v| 
     v.memory = 2048 
     v.cpus = 2 
    end 

    # Optional NFS. Make sure to remove other synced_folder line too 
    #config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] } 


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

      ## Only thing you probably really care about is right here 
      DOMAINS=("site1.dev" "site2.dev" "site3.dev" "site4.dev" "site5.dev" "ai.d$ 

      ## Loop through all sites 
      for ((i=0; i < ${#DOMAINS[@]}; i++)); do 

       ## Current Domain 
       DOMAIN=${DOMAINS[$i]} 

       echo "Creating directory for $DOMAIN..." 
       mkdir -p /var/www/$DOMAIN/public 

       echo "Creating vhost config for $DOMAIN..." 
       sudo cp /etc/apache2/sites-available/scotchbox.local.conf /etc/apache2/si$ 

       echo "Updating vhost config for $DOMAIN..." 
       sudo sed -i s,scotchbox.local,$DOMAIN,g /etc/apache2/sites-available/$DOM$ 
sudo sed -i s,/var/www/public,/var/www/$DOMAIN/public,g /etc/apache2/site$ 

       echo "Enabling $DOMAIN. Will probably tell you to restart Apache..." 
       sudo a2ensite $DOMAIN.conf 

      done 

     SHELL 
end 

做無業遊民時,直到它超時,但仍然盒開始和作品,我可以ssh到它與密碼,我也得到驗證錯誤。

我已經查看了很多其他問題,並嘗試了一些東西,但似乎沒有解決它。理想情況下,我想使用密鑰ssh,但會解決只是爲了回來,所以我可以配置它,並必須使用密碼登錄。

感謝

回答

0

我想通了這一點通過設置在我Vagrantfile以下使用,當它初始化的無業遊民創建SSH密鑰。

config.ssh.private_key_path = "/pathtovagrantfolder/.vagrant/machines/default/virtualbox/private_key"