无法连接到 homestead MySQL 数据库 - 权限被拒绝(公钥、密码)
Can't connect to homestead MySQL database - Permission denied (publickey,password)
我正在使用 Homestead 和 vagrant 进行我的本地设置。我的 Homestead.yaml 文件如下所示:
---
ip: "192.168.56.56"
memory: 4096
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/projects
to: /home/vagrant/projects
type: "nfs"
sites:
- map: volley.admin
to: /home/vagrant/projects/volleyadmin/public
type: laravel
php: "7.1"
databases:
- volleyadmin
features:
- mysql: true
- mariadb: false
- postgresql: false
- ohmyzsh: false
- webdriver: false
services:
- enabled:
- "mysql"
# - disabled:
# - "postgresql@11-main"
#ports:
# - send: 33060 # MySQL/MariaDB
# to: 3306
# - send: 4040
# to: 4040
# - send: 54320 # PostgreSQL
# to: 5432
# - send: 8025 # Mailhog
# to: 8025
# - send: 9600
# to: 9600
# - send: 27017
# to: 27017
我执行了 vagrant up 和 vagrant ssh,一切正常。问题是我无法使用 Sequel Ace.
连接到我的数据库
我的配置是这样的:
MySQL密码:秘密
SSH 密码:秘密
当我尝试连接时,我得到以下响应:
Used command: /usr/bin/ssh -v -N -S none -o ControlMaster=no -o ExitOnForwardFailure=yes -o ConnectTimeout=10 -o NumberOfPasswordPrompts=3 -o UserKnownHostsFile="/Users/nielsvroman/Library/Containers/com.sequel-ace.sequel-ace/Data/.keys/ssh_known_hosts_strict" -F /Applications/Sequel Ace.app/Contents/Resources/ssh_config -o TCPKeepAlive=no -o ServerAliveInterval=60 -o ServerAliveCountMax=1 vagrant@192.168.56.56 -L 50489:127.0.0.1:3306
OpenSSH_8.6p1, LibreSSL 3.3.5
debug1: Reading configuration data /Applications/Sequel Ace.app/Contents/Resources/ssh_config
debug1: /Applications/Sequel Ace.app/Contents/Resources/ssh_config line 1: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to 192.168.56.56 [192.168.56.56] port 22.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: identity file /Users/nielsvroman/.keys/id_rsa type -1
debug1: identity file /Users/nielsvroman/.keys/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.4
debug1: compat_banner: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.56.56:22 as 'vagrant'
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:r6W0RoVMAo3PNslyC8hel/ZlozmmV4vIpdulB7LmOEc
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '192.168.56.56' is known and matches the ED25519 host key.
debug1: Found key in /Users/nielsvroman/Library/Containers/com.sequel-ace.sequel-ace/Data/.keys/ssh_known_hosts_strict:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: Operation not permitted
debug1: Will attempt key: /Users/nielsvroman/.keys/id_rsa explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/nielsvroman/.keys/id_rsa
no such identity: /Users/nielsvroman/.keys/id_rsa: No such file or directory
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: Device not configured
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: Device not configured
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: Device not configured
debug1: Authentications that can continue: publickey,password
debug1: No more authentication methods to try.
vagrant@192.168.56.56: Permission denied (publickey,password).
The SSH Tunnel could not authenticate with the remote host. Please check your password and ensure you still have access.
您的 Homestead.yaml
文件表明您的 ssh 密钥文件位于其典型位置:~/.ssh/id_rsa
。但是,调试输出显示 ssh 正在另一个位置查找密钥:
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/nielsvroman/.keys/id_rsa
no such identity: /Users/nielsvroman/.keys/id_rsa: No such file or directory
^^^^^
它在 ~/.keys
而不是 ~/.ssh
中查找。密钥不在该位置,因此 ssh 找不到它,也不会将其呈现给远程系统。
根据调试输出中的“用户命令”行,ssh 运行 使用非标准配置文件 /Applications/Sequel Ace.app/Contents/Resources/ssh_config
。该文件可能包含一些配置选项,导致 ssh 在 .keys
目录而不是 .ssh
目录中查找密钥文件。
简单的解决方案是将密钥文件(id_rsa
和 _id_rsa.pub
)从 .ssh
目录复制到此 .keys
目录中。关键文件并不大,将它们放在多个地方也没有什么实际问题。
或者,您可以编辑这个特殊的 ssh 配置文件,使其在通常的位置查找关键文件。有必要确定导致 ssh 在其他目录中查找的配置选项,并更改或删除它们。看起来这个特殊的配置文件是您安装的某些软件的一部分?更改配置文件可能会影响软件的工作方式,或者可能会在每次更新软件时为您 re-edit 文件创建额外的工作。
我正在使用 Homestead 和 vagrant 进行我的本地设置。我的 Homestead.yaml 文件如下所示:
---
ip: "192.168.56.56"
memory: 4096
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/projects
to: /home/vagrant/projects
type: "nfs"
sites:
- map: volley.admin
to: /home/vagrant/projects/volleyadmin/public
type: laravel
php: "7.1"
databases:
- volleyadmin
features:
- mysql: true
- mariadb: false
- postgresql: false
- ohmyzsh: false
- webdriver: false
services:
- enabled:
- "mysql"
# - disabled:
# - "postgresql@11-main"
#ports:
# - send: 33060 # MySQL/MariaDB
# to: 3306
# - send: 4040
# to: 4040
# - send: 54320 # PostgreSQL
# to: 5432
# - send: 8025 # Mailhog
# to: 8025
# - send: 9600
# to: 9600
# - send: 27017
# to: 27017
我执行了 vagrant up 和 vagrant ssh,一切正常。问题是我无法使用 Sequel Ace.
连接到我的数据库我的配置是这样的:
MySQL密码:秘密 SSH 密码:秘密
当我尝试连接时,我得到以下响应:
Used command: /usr/bin/ssh -v -N -S none -o ControlMaster=no -o ExitOnForwardFailure=yes -o ConnectTimeout=10 -o NumberOfPasswordPrompts=3 -o UserKnownHostsFile="/Users/nielsvroman/Library/Containers/com.sequel-ace.sequel-ace/Data/.keys/ssh_known_hosts_strict" -F /Applications/Sequel Ace.app/Contents/Resources/ssh_config -o TCPKeepAlive=no -o ServerAliveInterval=60 -o ServerAliveCountMax=1 vagrant@192.168.56.56 -L 50489:127.0.0.1:3306
OpenSSH_8.6p1, LibreSSL 3.3.5
debug1: Reading configuration data /Applications/Sequel Ace.app/Contents/Resources/ssh_config
debug1: /Applications/Sequel Ace.app/Contents/Resources/ssh_config line 1: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to 192.168.56.56 [192.168.56.56] port 22.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: identity file /Users/nielsvroman/.keys/id_rsa type -1
debug1: identity file /Users/nielsvroman/.keys/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.4
debug1: compat_banner: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.56.56:22 as 'vagrant'
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:r6W0RoVMAo3PNslyC8hel/ZlozmmV4vIpdulB7LmOEc
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '192.168.56.56' is known and matches the ED25519 host key.
debug1: Found key in /Users/nielsvroman/Library/Containers/com.sequel-ace.sequel-ace/Data/.keys/ssh_known_hosts_strict:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: Operation not permitted
debug1: Will attempt key: /Users/nielsvroman/.keys/id_rsa explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/nielsvroman/.keys/id_rsa
no such identity: /Users/nielsvroman/.keys/id_rsa: No such file or directory
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: Device not configured
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: Device not configured
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: Device not configured
debug1: Authentications that can continue: publickey,password
debug1: No more authentication methods to try.
vagrant@192.168.56.56: Permission denied (publickey,password).
The SSH Tunnel could not authenticate with the remote host. Please check your password and ensure you still have access.
您的 Homestead.yaml
文件表明您的 ssh 密钥文件位于其典型位置:~/.ssh/id_rsa
。但是,调试输出显示 ssh 正在另一个位置查找密钥:
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/nielsvroman/.keys/id_rsa
no such identity: /Users/nielsvroman/.keys/id_rsa: No such file or directory
^^^^^
它在 ~/.keys
而不是 ~/.ssh
中查找。密钥不在该位置,因此 ssh 找不到它,也不会将其呈现给远程系统。
根据调试输出中的“用户命令”行,ssh 运行 使用非标准配置文件 /Applications/Sequel Ace.app/Contents/Resources/ssh_config
。该文件可能包含一些配置选项,导致 ssh 在 .keys
目录而不是 .ssh
目录中查找密钥文件。
简单的解决方案是将密钥文件(id_rsa
和 _id_rsa.pub
)从 .ssh
目录复制到此 .keys
目录中。关键文件并不大,将它们放在多个地方也没有什么实际问题。
或者,您可以编辑这个特殊的 ssh 配置文件,使其在通常的位置查找关键文件。有必要确定导致 ssh 在其他目录中查找的配置选项,并更改或删除它们。看起来这个特殊的配置文件是您安装的某些软件的一部分?更改配置文件可能会影响软件的工作方式,或者可能会在每次更新软件时为您 re-edit 文件创建额外的工作。