jeroenpeeters / docker-ssh

SSH Server for Docker containers ~ Because every container should be accessible
GNU General Public License v2.0
638 stars 89 forks source link

PTY allocation request failed #38

Open tkambler opened 6 years ago

tkambler commented 6 years ago

I'm following the instructions and am receiving the following error when attempting to connect via SSH:

PTY allocation request failed on channel 0
shell request failed on channel 0
laur89 commented 4 years ago

Unsure if related, but sometimes docker-ssh logs also this error:

docker-ssh | [2019-10-06T14:57:25.199Z]  INFO: sshServer/38 on a0be7e038ef6: Client connected (clientIp=172.18.0.1)
docker-ssh | [2019-10-06T14:57:25.231Z] ERROR: noAuthHandler/38 on a0be7e038ef6: NoAuthentication handler is handling the authentication! This is INSECURE!
docker-ssh | [2019-10-06T14:57:25.252Z]  INFO: sessionHandler/38 on a0be7e038ef6: Opening shell
docker-ssh | /usr/src/app/src/session-handler-factory.coffee:21
docker-ssh |       for (i = j = 0, ref = length - text.length; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {
docker-ssh |                                          ^
docker-ssh | 
docker-ssh | TypeError: Cannot read property 'length' of undefined
docker-ssh |   at /usr/src/app/src/session-handler-factory.coffee:7:41
docker-ssh |   at spaces (/usr/src/app/src/session-handler-factory.coffee:25:7)
docker-ssh |   at header (/usr/src/app/src/session-handler-factory.coffee:13:34)
docker-ssh |   at Session.<anonymous> (/usr/src/app/src/session-handler-factory.coffee:81:28)
docker-ssh |   at emitTwo (events.js:106:13)
docker-ssh |   at Session.emit (events.js:191:7)
docker-ssh |   at SSH2Stream.onREQUEST (/usr/src/app/node_modules/ssh2/lib/server.js:653:16)
docker-ssh |   at emitOne (events.js:96:13)
docker-ssh |   at SSH2Stream.emit (events.js:188:7)
docker-ssh |   at parse_CHANNEL_REQUEST (/usr/src/app/node_modules/ssh2-streams/lib/ssh.js:4356:8)
docker-ssh |   at parsePacket (/usr/src/app/node_modules/ssh2-streams/lib/ssh.js:3727:12)
docker-ssh |   at SSH2Stream._transform (/usr/src/app/node_modules/ssh2-streams/lib/ssh.js:551:13)
docker-ssh |   at SSH2Stream.Transform._read (_stream_transform.js:167:10)
docker-ssh |   at SSH2Stream._read (/usr/src/app/node_modules/ssh2-streams/lib/ssh.js:212:15)
docker-ssh |   at SSH2Stream.Transform._write (_stream_transform.js:155:12)
docker-ssh |   at doWrite (_stream_writable.js:331:12)
docker-ssh |   at writeOrBuffer (_stream_writable.js:317:5)
docker-ssh |   at SSH2Stream.Writable.write (_stream_writable.js:243:11)
docker-ssh |   at Socket.ondata (_stream_readable.js:555:20)
docker-ssh |   at emitOne (events.js:96:13)
docker-ssh |   at Socket.emit (events.js:188:7)
docker-ssh |   at readableAddChunk (_stream_readable.js:176:18)
docker-ssh |   at Socket.Readable.push (_stream_readable.js:134:10)
docker-ssh |   at TCP.onread (net.js:547:20)
docker-ssh | 
docker-ssh | error: Forever detected script exited with code: 1
docker-ssh | error: Script restart attempt #2

docker-ssh was started via docker-compse with

    image: jeroenpeeters/docker-ssh
    container_name: docker-ssh
    environment:
      - AUTH_MECHANISM=noAuth
      - FILTERS='{"name":["^/container-dev$$"]}'
    ports:
      - "22:22"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
anki-code commented 4 years ago

The issue is actual. I observe the error which @laur89 describe and after this I see the error from the @tkambler message when I try to make ssh connection from one container to another.

UPD: as result I use https://github.com/linuxserver/docker-openssh-server

segadora commented 4 years ago

Im getting the same error, but without exception

areshytko commented 3 years ago

the same error for me. unstarred the repo because the ticket is already 3 years old and there's no activity around it

areshytko commented 3 years ago

Update from my side. The bug appears on Mac OS docker, but everything works on Linux host system:

To reproduce:

docker run --name myubuntu  --rm -d ubuntu:20.04 sleep 1000
docker run -d -p 2222:22 -v /var/run/docker.sock:/var/run/docker.sock -e FILTERS="{\"name\":[\"^/myubuntu$\"]}" -e AUTH_MECHANISM=simpleAuth -e AUTH_USER=ubuntu -e AUTH_PASSWORD=1234 jeroenpeeters/docker-ssh
ssh ubuntu@localhost -p 2222
silgonel commented 2 years ago

Hello! I was having this issue on a Linux host system as well, with a custom container. This is what worked for me, in case it can be useful for someone else:

ON SERVER docker run -e FILTERS={\"name\":[\"^/my_container$\"]} -e AUTH_MECHANISM=simpleAuth -e AUTH_USER=ubuntu -e AUTH_PASSWORD=1234 --name sshd-web-server1 -p 2222:22 --rm -v /var/run/docker.sock:/var/run/docker.sock jeroenpeeters/docker-ssh

ON CLIENT ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -t ubuntu@localhost -p 2222

First parameter ("-oKexAlgorithms") was to solve this error: "Unable to negotiate with 127.0.0.1 port 2222: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1"

Parameter ("-t") solved the other two errors and allowed me to access (as suggested here: [https://stackoverflow.com/questions/10330678/gitolite-pty-allocation-request-failed-on-channel-0])

bonelifer commented 8 months ago

@silgonel that got me to this: Unable to negotiate with 127.0.0.1 port 2222: no matching host key type found. Their offer: ssh-rsa

@jeroenpeeters is this project abandoned?