【问题标题】:Connection to MySQL via Vagrant not working anymore since El Capitan自 El Capitan 以来,通过 Vagrant 与 MySQL 的连接不再有效
【发布时间】:2016-01-03 13:53:27
【问题描述】:

我正在使用 vagrant,我正在使用以下配置连接到我的数据库。

SSH 密码是/.vagrant/machines/default/virtualbox/ 文件夹中的private_key 文件。这没有任何问题,但由于我已经更新到 El Capitan,我无法连接。

我正在了解这些详细信息

Querious 无法创建 SSH 连接,因为远程主机拒绝了权限。

仔细检查 SSH 用户名和密码(或公钥,如果使用基于密钥的身份验证)是否正确。

OpenSSH_6.9p1, LibreSSL 2.1.7
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/tzfrs/work/Server/194.6.226.31/.vagrant/machines/default/virtualbox/private_key type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/tzfrs/work/Server/194.6.226.31/.vagrant/machines/default/virtualbox/private_key-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4+deb7u2
debug1: match: OpenSSH_6.0p1 Debian-4+deb7u2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 127.0.0.1:2222 as 'vagrant'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr umac-64@openssh.com none
debug1: kex: client->server aes128-ctr umac-64@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:kBFNbCLWp1m4X03xMWxWeCjaQUEa426OsJ5IC/PNisM
debug1: Host '[127.0.0.1]:2222' is known and matches the RSA host key.
debug1: Found key in /Users/tzfrs/.ssh/known_hosts:11
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/tzfrs/work/Server/194.6.226.31/.vagrant/machines/default/virtualbox/private_key
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: Device not configured
debug1: permanently_drop_suid: 502
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.

根据要求,这是vagrant ssh-config的输出

Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/tzfrs/work/Server/194.6.226.31/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

我必须做些什么才能让它再次工作?

【问题讨论】:

  • 你能vagrant ssh吗?你能粘贴vagrant ssh-config的输出吗
  • 我可以毫无问题地连接。
  • ssh-configpastebin.com/9mNARCFe

标签: mysql macos ssh vagrant


【解决方案1】:

我有同样的问题,用 PSequel 连接到 Vagrant 框中的 Postgresql 数据库。同一解决方案的两种变体:

流浪钥匙

  • 执行vagrant ssh-config
  • 您会看到一行 IdentityFile 包含类似 /Users/stefbastiaansen/vm/precise-pangolin/.vagrant/machines/default/virtualbox/private_key 的内容
  • 在新的终端窗口中连接到ssh -p 2222 -i /Users/yourusername/vm/precise-pangolin/.vagrant/machines/default/virtualbox/private_key vagrant@127.0.0.1
  • 您会收到无法确认主机 (127.0.0.1:2222) 真实性的通知,以及是否确定要继续连接的问题。回答是。
  • 然后打开 PSequel (Postgres) 或 Sequel Pro (MySQL) 并将其配置为 SSH 隧道。

    • 主机:127.0.0.1
    • 端口:2222
    • 用户:流浪者
    • 身份文件:/Users/yourusername/vm/precise-pangolin/.vagrant/machines/default/virtualbox/private_key
  • 连接。

您自己的密钥

  • 将您的公钥复制到剪贴板:pbcopy < ~/id_rsa.pub
  • ssh vagrant
  • 将您的公钥添加到 vagrant box 上的~/.ssh/authorized_keys
  • 打开一个新的终端窗口
  • ssh -p 2222 vagrant@127.0.0.1
  • 您会收到无法确认主机 (127.0.0.1:2222) 真实性的通知,以及是否确定要继续连接的问题。回答是。
  • 然后打开 PSequel (Postgres) 或 Sequel Pro (MySQL) 并将其配置为 SSH 隧道。

    • 主机:127.0.0.1
    • 端口:2222
    • 用户:流浪者
    • 身份文件:~/.ssh/id_rsa
  • 连接。

这是在您可以通过 ssh 连接之前需要进行的确认步骤。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-28
    • 1970-01-01
    • 2016-08-09
    • 2016-03-08
    相关资源
    最近更新 更多