6

我在 Google Cloud 虚拟机上运行 docker 容器。我尝试了几个小时从本地计算机上的 filezilla 连接到正在运行的 docker 容器。我已经像这样启动了 docker 镜像:

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

在我的filezilla连接配置中,我设置了:

主机:谷歌云IP地址
端口:2222
协议:SFTP
登录类型:普通
用户:root(无密码)

尝试连接时出现此错误:

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

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

4

2 回答 2

4

首先,不建议在 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 容器。

于 2017-03-16T13:24:11.183 回答
0

您必须sudo nano /etc/ssh/sshd_config,然后使用 Ctrl + W 搜索PasswordAuth并将其修改为是。

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

于 2017-02-28T03:38:56.833 回答