SSH to docker container is not working

6,057

The issue is fixed now.

seems to be an issue with Discourse SSH container configuration,

In /etc/ssh/sshd_config

PermitRootLogin without-password

I've changed it to

PermitRootLogin yes

#PermitRootLogin without-password

That fixed the issue.

Share:
6,057

Related videos on Youtube

Augustin
Author by

Augustin

Updated on September 18, 2022

Comments

  • Augustin
    Augustin over 1 year

    I'm running a Discourse forum software container in an Ubuntu Server, I was able to login to container using the command.

    sudo docker exec -it app bash

    And then I've setup password for the root user, but the ssh is not working as expected always getting incorrect password.

    SSH debug log

    Set /proc/self/oom_score_adj to 0
    debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
    debug1: inetd sockets after dupping: 3, 3
    Connection from ::1 port 45924 on ::1 port 22
    debug1: Client protocol version 2.0; client software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
    debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
    debug1: permanently_set_uid: 105/65534 [preauth]
    debug1: list_hostkey_types: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
    debug1: SSH2_MSG_KEXINIT sent [preauth]
    debug1: SSH2_MSG_KEXINIT received [preauth]
    debug1: kex: client->server aes128-ctr [email protected] none [preauth]
    debug1: kex: server->client aes128-ctr [email protected] none [preauth]
    debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
    debug1: SSH2_MSG_NEWKEYS sent [preauth]
    debug1: expecting SSH2_MSG_NEWKEYS [preauth]
    debug1: SSH2_MSG_NEWKEYS received [preauth]
    debug1: KEX done [preauth]
    debug1: userauth-request for user root service ssh-connection method none [preauth]
    debug1: attempt 0 failures 0 [preauth]
    debug1: PAM: initializing for "root"
    debug1: PAM: setting PAM_RHOST to "localhost"
    debug1: PAM: setting PAM_TTY to "ssh"
    debug1: userauth-request for user root service ssh-connection method password [preauth]
    debug1: attempt 1 failures 0 [preauth]
    pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=localhost  user=root
    debug1: PAM: password authentication failed for root: Authentication failure
    Failed password for root from ::1 port 45924 ssh2
    Excess permission or bad ownership on file /var/log/btmp
    Connection closed by ::1 [preauth]
    debug1: do_cleanup [preauth]
    debug1: monitor_read_log: child log fd closed
    debug1: do_cleanup
    debug1: PAM: cleanup
    debug1: Killing privsep child 32712
    

    Please advise.

    • Augustin
      Augustin over 8 years
      The ssh was already enabled the container, its a container running Discourse forum software, what I did was change the password for root user. root@forum:/# id uid=0(root) gid=0(root) groups=0(root) root@forum:/# passwd Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully root@forum:/# ssh localhost root@localhost's password: Permission denied, please try again. root@localhost's password:
    • Klaatu von Schlacker
      Klaatu von Schlacker over 8 years
      For testing sake, what happens if you try to ssh in as a non-root user?
  • Augustin
    Augustin over 8 years
    Already tried restarting the ssh service and changing password, still no luck.