vagrant box打包前的准备

非强制,如打算分发此box,建议遵循如下约定

  • Hostname:vagrant-[os-name],例:vagrant-ubuntu-Steve
  • Domain: vagrantup.com
  • Root Password: vagrant
  • Main account login: vagrant
  • Main account password: vagrant

1、登陆到ubuntu系统,添加用户

sudo useradd vagrant -m

2、修改vagrant用户的密码

sudo passwd vagrant

按提示输入两次新密码

3、创建admin组

sudo groupadd admin

4、添加vagrant用户到admin组

sudo usermod -G admin vagrant

5、安装vagrant的public keys

sudo mkdir /home/vagrant/.ssh/
sudo -u vagrant wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys

下载公钥另外的地址

sudo -u vagrant wget http://github.com/mitchellh/vagrant/raw/master/keys/vagrant -O /home/vagrant/.ssh/vagrant
sudo -u vagrant wget http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys

6、修改authorized_keys文件权限 除了属主vagrant以外,group和其他用户都不可写

sudo -u vagrant chmod 700 /home/vagrant/.ssh
sudo -u vagrant chmod 600 /home/vagrant/.ssh/authorized_keys
sudo -u vagrant chown -R vagrant:vagrant /home/vagrant/.ssh

 修改文件权限另一种方法

chmod go-w /home/vagrant/.ssh/authorized_keys
cat .ssh/authorized_keys

7、清除缓存

sudo apt-get clean

 

posted @ 2019-03-04 16:35  零散碎语  阅读(536)  评论(0编辑  收藏  举报