多年来,我一直在 Windows 10 上成功使用 Vagrant 2.2.4。我基于 Ubuntu 14.04 创建了一个自定义框,并且能够使用 登录vagrant ssh
。
我创建了一个新的测试项目来尝试使用新盒子:
$ mkdir ~/vagrant_test
$ cd ~/vagrant_test
$ vagrant init ubuntu/jammy64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
我编辑了Vagrantfile
最少的选项:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/jammy64"
config.vm.synced_folder ".", "/vagrant"
end
然而,vagrant up
测试项目失败:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/jammy64' version '20230314.0.0' is up to date...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection aborted. Retrying...
The private key you're attempting to use with this Vagrant box uses
an unsupported encryption type. The SSH library Vagrant uses does not support
this key type. Please use `ssh-rsa` or `ssh-dss` instead. Note that
sometimes keys in your ssh-agent can interfere with this as well,
so verify the keys are valid there in addition to standard
file paths.
测试项目:
$ cd ~/vagrant_test
$ vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2200
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Users/Ryan/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
使用自定义框处理现有项目:
$ cd ~/job_tracker
$ vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Users/Ryan/.vagrant.d/boxes/seaportstainless-VAGRANTSLASH-job_tracker/1.0.0/virtualbox/vagrant_private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes
尝试通过 SSH 进入测试项目框:
$ cd ~/vagrant_test
$ vagrant ssh -- -v
OpenSSH_7.9p1, OpenSSL 1.1.1a 20 Nov 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2200.
debug1: Connection established.
debug1: identity file C:/Users/Ryan/.vagrant.d/insecure_private_key type -1
debug1: identity file C:/Users/Ryan/.vagrant.d/insecure_private_key-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
debug1: match: OpenSSH_8.9p1 Ubuntu-3ubuntu0.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 127.0.0.1:2200 as 'vagrant'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: [email protected]
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: [email protected]
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:YLUw1a2RC1Dm4YAbjyXxg8BiH3vWZ8okfVT3hDgTKik
debug1: checking without port identifier
Warning: Permanently added '[127.0.0.1]:2200' (ECDSA) to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: C:/Users/Ryan/.vagrant.d/insecure_private_key explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: kex_input_ext_info: [email protected] (unrecognised)
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: C:/Users/Ryan/.vagrant.d/insecure_private_key
Enter passphrase for key 'C:/Users/Ryan/.vagrant.d/insecure_private_key':
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).
编辑于4/12/23: 我尝试手动通过 SSH 进入新的 Vagrant 框并收到远程主机警告:
$ ssh -i /c/Users/Ryan/.vagrant.d/insecure_private_key -o PasswordAuthentication=no [email protected] -p 2222
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:********************
Please contact your system administrator.
Add correct host key in /c/Users/Ryan/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /c/Users/Ryan/.ssh/known_hosts:7
ECDSA host key for [127.0.0.1]:2222 has changed and you have requested strict checking.
Host key verification failed.
我从known_hosts中删除了localhost
和127.0.0.1
,然后我能够手动通过 SSH 进入新的 Vagrant 框:
$ ssh -i /c/Users/Ryan/.vagrant.d/insecure_private_key -o PasswordAuthentication=no [email protected] -p 2222
The authenticity of host '[127.0.0.1]:2222 ([127.0.0.1]:2222)' can't be established.
ECDSA key fingerprint is SHA256:**************.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-69-generic x86_64)
但是,当我尝试通过登录时,仍然收到相同的“不支持的加密类型”错误vagrant ssh
。