docker-ssh icon indicating copy to clipboard operation
docker-ssh copied to clipboard

ssh into container immediately closes the connection

Open mpodber1971 opened this issue 9 years ago • 7 comments

i ran this command from the instance where docker resides: sudo docker run -d -p 2222:22
-v /var/run/docker.sock:/var/run/docker.sock
-e CONTAINER=matt -e AUTH_MECHANISM=noAuth
jeroenpeeters/docker-ssh

i run the ssh command to the instance: ssh -p 2222 -i <KEY_LOCATION> user@ipaddress

and get the following dialogue before it closes the connection immediately

###############################################################

Docker SSH ~ Because every container should be accessible

###############################################################

container | matt

###############################################################

Connection to XX.XXX.XX.XXX closed by remote host. Connection to XX.XXX.XX.XXX closed.

mpodber1971 avatar May 23 '16 14:05 mpodber1971

does the sshd service need to be running on the container?

mpodber1971 avatar May 23 '16 14:05 mpodber1971

Are you running Docker on Windows? If so check #7.

tikoflano avatar Jun 03 '16 18:06 tikoflano

Had a similar issue today and it turned out to be a typo and permissions on the /var/run/docker.sock and in your case it could be permissions too. Try changing the volume flag to:

-v /var/run/docker.sock:/var/run/docker.sock:Z

That should setup SELinux permissions correctly if that happens to be the issue.

alexmipego avatar Jul 19 '16 13:07 alexmipego

I have the same issue on ubuntu the client and on the server and logs return:

/src/src/session-handler-factory.coffee:156
                  stream.on('data', function(data) {
                        ^

TypeError: Cannot read property 'on' of null
  at Object.callback (/src/src/session-handler-factory.coffee:79:19)
  at /src/node_modules/dockerode/lib/exec.js:39:10
  at Modem.buildPayload (/src/node_modules/docker-modem/lib/modem.js:225:19)
  at ClientRequest.<anonymous> (/src/node_modules/docker-modem/lib/modem.js:210:10)
  at emitOne (events.js:96:13)
  at ClientRequest.emit (events.js:188:7)
  at writeAfterEndNT (_http_outgoing.js:486:8)
  at _combinedTickCallback (internal/process/next_tick.js:77:11)
  at process._tickCallback (internal/process/next_tick.js:98:9)

mgomma avatar Aug 23 '16 08:08 mgomma

+1

Darwin mbp-user 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64

Docker version 1.13.0, build 49bf474

piotr-s-brainhub avatar Feb 07 '17 16:02 piotr-s-brainhub

@mgomma i had the same issue, building the dockerfile in this git repository again resolved the issue

Also i had to quote this with single quotes FILTERS={\"name\":[\"^/my-container$\"]}

The full command

docker run -e 'FILTERS={\"name\":[\"^/my-container$\"]}' -e AUTH_MECHANISM=simpleAuth -e AUTH_USER=sshd -e AUTH_PASSWORD=1234 --name sshd -p 2222:22 --rm -v /var/run/docker.sock:/var/run/docker.sock docker-ssh

Note during the build i encountered the following warnings:


> [email protected] install /usr/src/app/node_modules/dtrace-provider
> node scripts/install.js

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 209 packages in 5.672s
npm WARN using --force I sure hope you know what you are doing.

This works on Docker For Windows

 Version:      18.05.0-ce-rc1
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   33f00ce
 Built:        Thu Apr 26 00:57:53 2018
 OS/Arch:      windows/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.05.0-ce-rc1
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.10.1
  Git commit:   33f00ce
  Built:        Thu Apr 26 01:06:49 2018
  OS/Arch:      linux/amd64
  Experimental: true```

Metachemix1 avatar Apr 27 '18 14:04 Metachemix1

hi all, i got this kind of error too.

I forget that to installed the "bash" into the objective container, eg. in alpine image, "apk add bash".

chungyan5 avatar Nov 04 '19 01:11 chungyan5