首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ssh隧道-绑定:已在使用的地址

ssh隧道-绑定:已在使用的地址
EN

Ask Ubuntu用户
提问于 2021-02-27 17:38:07
回答 1查看 4.9K关注 0票数 0

我正在运行我的VPS Ubuntu 20.04.1 LTS和本地Ubuntu 18.04.3 LTS,我想创建一个ssh隧道来连接到我的数据库,运行SELECT's在我的laravel 6应用程序中进行报告。

我的生产数据库在我的服务器上有以下凭证:

代码语言:javascript
复制
DB_HOST_PROD=127.0.0.1
DB_PORT_PROD=3306
DB_DATABASE_PROD=test_db
DB_USERNAME_PROD=root
DB_PASSWORD_PROD=prod_pwd

在运行我的ssh-command时,我得到:

代码语言:javascript
复制
admin@admin-VirtualBox:~$ /usr/bin/ssh -o StrictHostKeyChecking=no -v -N -i /home/admin/.ssh/id_rsa -L 13307:127.0.0.1:3306 -p 22 root@xx.xx.xxx.xx
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to xx.xx.xxx.xx [xx.xx.xxx.xx] port 22.
debug1: Connection established.
debug1: identity file /home/admin/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/admin/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to xx.xx.xxx.xx:22 as 'root'
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: 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: Server host key: ecdsa-sha2-nistp256 SHA256:aaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa
debug1: Host 'xx.xx.xxx.xx' is known and matches the ECDSA host key.
debug1: Found key in /home/admin/.ssh/known_hosts:1
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: 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: Offering public key: RSA SHA256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa /home/admin/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
debug1: Authentication succeeded (publickey).
Authenticated to xx.xx.xxx.xx ([xx.xx.xxx.xx]:22).
debug1: Local connections to LOCALHOST:13307 forwarded to remote address 127.0.0.1:3306
debug1: Local forwarding listening on ::1 port 13307.
bind: Address already in use
debug1: Local forwarding listening on 127.0.0.1 port 13307.
bind: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 13307
Could not request local forwarding.
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Remote: /root/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /root/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding

我正在本地运行我的开发数据库:

代码语言:javascript
复制
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test_db
DB_USERNAME=root
DB_PASSWORD=local_pwd

为什么我要收到消息bind: Address already in use

有什么建议我做错了吗?

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2021-02-27 19:08:12

这条信息是不言而喻的。有些程序已经在使用端口13307。尝试以根用户身份运行netstat -antp,查找端口13307,您应该会看到相关程序的PID。您可能已经有一个过时的SSH连接。另外,您可能需要反向SSH的-R选项。

可能有用的帖子:知道远程端口转发是否成功?

票数 3
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1319847

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档