Tirafesi
Tirafesi

Reputation: 1479

Can't ssh into docker container

I'm trying to run an openssh-server container and then connect to it:

docker run \
    --name=openssh-server \
    -p 22:22 \
    -e USER_PASSWORD=123 \
    -e USER_NAME=testuser \
    --restart unless-stopped \
    linuxserver/openssh-server
ssh testuser@localhost

The problem I'm having is that I keep getting the error ssh_exchange_identification: read: Connection reset by peer. What am I doing wrong?

Upvotes: 0

Views: 536

Answers (1)

Munish
Munish

Reputation: 1637

Add -e PASSWORD_ACCESS=true in command to allow username/password ssh access and change -p 22:22 to 22:2222 as container always starts openssh on port 2222
Updated command is ::

docker run \
    --name=openssh-server \
    -p 22:2222 \
    -e USER_PASSWORD=123 \
    -e USER_NAME=testuser \
    -e PASSWORD_ACCESS=true \
    --restart unless-stopped \
    linuxserver/openssh-server

Upvotes: 1

Related Questions