我已经在远程机器上的 docker 中安装了 GitLab。我现在想将这个远程机器的端口 8080 转发到我的本地端口 8080。
在远程机器上:
sudo docker run --detach --hostname gitlab.example.com --publish 443:443 --publish 8080:80 --publish 2222:22 --name gitlab --restart always --volume $GITLAB_HOME/config:/etc/gitlab --volume $GITLAB_HOME/logs:/var/log/gitlab --volume $GITLAB_HOME/data:/var/opt/gitlab gitlab/gitlab-ce:latest
在我的本地机器上:
ssh -N -o "ExitOnForwardFailure yes" -R 8080:localhost:8080 someuser@the-distant-server -vvv
我收到以下错误:
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug3: receive packet: type 4
debug1: Remote: /home/someuser/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 82
debug1: remote forward failure for: listen 8080, connect localhost:8080
Error: remote port forwarding failed for listen port 8080
实际上,在 中/var/log/auth.log
,我收到以下错误:
Jul 9 16:51:42 distant-server sshd[2723782]: Accepted publickey for someuser from 192.168.200.182 port 44850 ssh2: RSA SHA256:
Jul 9 16:51:42 distant-server sshd[2723782]: pam_unix(sshd:session): session opened for user someuser by (uid=0)
Jul 9 16:51:42 distant-server systemd-logind[1083]: New session 116923 of user someuser.
Jul 9 16:51:42 distant-server systemd[2723795]: pam_unix(systemd-user:session): session opened for user someuser by (uid=0)
Jul 9 16:51:43 distant-server sshd[2723812]: error: bind [127.0.0.1]:8080: Address already in use
Jul 9 16:51:43 distant-server sshd[2723812]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 8080
Jul 9 16:51:43 distant-server sshd[2723782]: pam_unix(sshd:session): session closed for user someuser
Jul 9 16:51:43 distant-server systemd-logind[1083]: Session 116923 logged out. Waiting for processes to exit.
Jul 9 16:51:43 distant-server systemd-logind[1083]: Removed session 116923.
它告诉我bind [127.0.0.1]:8080: Address already in use
。
- 如果没有进程可以写入,我不明白如何从远程机器监听端口 8080。我想我对端口/侦听/写作/ssh 在这里的工作方式有误解。
- 如何修复
ssh
命令以使此隧道工作并访问我的 GitLab 实例127.0.0.1:8080
?