执行反向ssh时出错

时间:2017-07-19 03:52:40

标签: linux ssh

我刚刚开始工作,我不熟悉使用ssh,我正在尝试创建一个从服务器到我家机器的反向ssh隧道。

我开始输入

ssh -v -f -R port-number1:localhost:port-number2 username@server-name

这很有用。但是,当我输入ssh -v -p port-number1 localhost时,会出现此错误。

OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 52673.
debug1: Connection established.
debug1: SELinux support disabled
Could not create directory '/home/dev/.ssh'.
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
ssh_exchange_identification: Connection closed by remote host

现在不知何故,我在服务器上的用户名是' dev'这是根目录中的文件夹,在主目录中有一个名为ubuntu的文件夹。当我尝试在服务器中找到.ssh时,它会显示home / ubuntu / .ssh 这可能是问题,但我不知道接下来该做什么,因为我无法访问服务器中的目录。

1 个答案:

答案 0 :(得分:0)

在远程主机上运行:

ssh -N user@remotehost -R port:localhost:port

如果用户是remotehost上的用户,则remotehost是您要反向ssh的框的IP /域,port是使用的端口(通常为22,但如果不是保留端口则可以是任意的),而localhost实际上是localhost。

然后尝试ssh到远程主机。