Skip to content

Latest commit

 

History

History
50 lines (48 loc) · 2.99 KB

使用说明.md

File metadata and controls

50 lines (48 loc) · 2.99 KB

vagrant官方镜像的说明

官方镜像可能比较坑,亲测得出来的结论

官方的Centos镜像的Vagrantfile配置文件在首次登录不能设置账号密码,自己在官方镜像的基础上制作的镜像,Vagrantfile必须配账号密码,官方的Ubuntu镜像默认是没安装ssh吗?

原因

官方的CentOS-7-x86_64-Vagrant-1805_01.VirtualBox.box和CentOS-7-x86_64-Vagrant-1809_01.VirtualBox.box 镜像的/etc/ssh/sshd_config文件配置都是不允许任何账号远程登录的,必须要改了里面参数PubkeyAuthentication=yes, PasswordAuthentication=yes,GSSAPIAuthentication=no,才允许任何账号远程登录,但是官方却没有特别说明,会坑了很多人, 所以跑官方镜像,都不能设置账号密码,设置了就会以账号密码登录,但是账号密码登录不了,结果导致不停重试浪费时间

官方的Centos镜像首次创建,都不能设置账号密码,默认先以私钥登录,再以vagrant账号密码登录(此时宿主机127.0.0.1:2222端口映射到镜像的22端口,不属于远程登录)

Bringing machine 'template' up with 'virtualbox' provider...
==> template: Importing base box 'centos-1809'...
==> template: Matching MAC address for NAT networking...
==> template: Setting the name of the VM: template
==> template: Clearing any previously set network interfaces...
==> template: Preparing network interfaces based on configuration...
    template: Adapter 1: nat
    template: Adapter 2: hostonly
==> template: Forwarding ports...
    template: 22 (guest) => 2222 (host) (adapter 1)
==> template: Running 'pre-boot' VM customizations...
==> template: Booting VM...
==> template: Waiting for machine to boot. This may take a few minutes...
    template: SSH address: 127.0.0.1:2222
    template: SSH username: vagrant
    template: SSH auth method: private key
    template:
    template: Vagrant insecure key detected. Vagrant will automatically replace
    template: this with a newly generated keypair for better security.
    template:
    template: Inserting generated public key within guest...
    template: Removing insecure key from the guest if it's present...
    template: Key inserted! Disconnecting and reconnecting using new SSH key...
==> template: Machine booted and ready!
==> template: Checking for guest additions in VM...
    template: No guest additions were detected on the base box for this VM! Guest
    template: additions are required for forwarded ports, shared folders, host only
    template: networking, and more. If SSH fails on this machine, please install
    template: the guest additions and repackage the box to continue.
    template:
    template: This is not an error message; everything may continue to work properly,
    template: in which case you may ignore this message.
==> template: Setting hostname...
==> template: Configuring and enabling network interfaces...
    template: SSH address: 127.0.0.1:2222
    template: SSH username: vagrant
    template: SSH auth method: private key