连接filezilla到docker集装箱

我在Google Cloud虚拟机上运行Docker容器。 我尝试了几个小时,从我的本地计算机上的filezilla连接到正在运行的docker集装箱。 我已经开始像这样的docker形象:

docker run -t -d --name test -p 2222:22 --link postgres7:postgres7 random_image /bin/bash 

在我的filezilla连接configuration我已经设置:

主持人:Google云端IP地址
港口:2222
协议:SFTP
logintypes:正常
用户:root(没有密码)

当试图连接时,我得到这个错误:

 Status: Connecting to xxxx:2222... Response: fzSftp started Command: open "root@xxxx" 2222 Error: Connection refused Error: Could not connect to server 

我在谷歌云引擎上打开了端口。

您必须sudo nano /etc/ssh/sshd_config ,然后使用Ctrl + WsearchPasswordAuth并将其修改为yes。

然后,您可以通过sftp://通过端口22尝试login您的IP。

首先,不build议在docker容器上安装ssh服务器,但这是我做的:

  1. 安装ssh客户端

apt-get install openssh-server

  1. 在root上设置密码(或任何你想连接的用户)

passwd (enter password twice)

  1. 在/ etc / ssh / sshd_config中更改:

PermitRootLogin without-password

PermitRootLogin yes

  1. 重新启动ssh服务器

/etc/init.d/ssh restart

现在,您将能够以root身份连接到任何ftp客户端,并使用您设置的密码连接到您的Docker容器。