Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How troubleshoot SSHd on Docker ? #1893

Closed
ygbillet opened this issue Nov 4, 2015 · 29 comments
Closed

How troubleshoot SSHd on Docker ? #1893

ygbillet opened this issue Nov 4, 2015 · 29 comments
Labels
📦 deployment Related to deployments
Milestone

Comments

@ygbillet
Copy link

ygbillet commented Nov 4, 2015

Hi,

I use GOGS as Docker appliance.
I just update to the last version.

I added my public key to my account.
Try to connect with ssh -vT git myhostname and get Permission denied (publickey,keyboard-interactive).

I check /home/git/.ssh/.authorized_keys and seems OK.
Is there a way to troubleshoot OpenSSH in GOGS running in Docker (where are the logs ?) ?

@unknwon
Copy link
Member

unknwon commented Nov 4, 2015

Permission denied (publickey,keyboard-interactive)

Get into Docker and check SSH auth.log.

@unknwon unknwon added 📦 deployment Related to deployments status: needs feedback Tell me more about it labels Nov 4, 2015
@unknwon unknwon added this to the 0.7.0 milestone Nov 4, 2015
@unknwon
Copy link
Member

unknwon commented Nov 4, 2015

cc @0rax

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

Did not find "auth.log" file in my container.

Am i missing something ?

@unknwon
Copy link
Member

unknwon commented Nov 4, 2015

Check if /home/git/.ssh/.authorized_keys's permission is 600.

@0rax
Copy link
Contributor

0rax commented Nov 4, 2015

Can you try to connect to your serveur via ssh ?

ssh git@my-server.ext

It should output

Hi there, You've successfully authenticated, but Gogs does not provide shell access.
If this is unexpected, please log in with password and setup Gogs under another user.
Connection to my-server.ext closed.

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

permission is 600.

Cannot connect to ssh (Permission denied)

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

  • Service SSH is up and running (get Permission denied and OK from ps)

  • authorized_key's permission is 600 and public key is in file.

    1 root 0:00 /usr/bin/s6-svscan /app/gogs/docker/s6/
    13 root 0:00 s6-supervise gogs
    14 root 0:00 s6-supervise openssh
    15 root 0:00 /usr/sbin/sshd -D -f /app/gogs/docker/sshd_config
    16 git 0:00 /app/gogs/gogs web
    61 root 0:00 /bin/bash
    73 root 0:00 ps

Bun cannot find auth.log or any log from openssh.

@0rax
Copy link
Contributor

0rax commented Nov 4, 2015

To get access to sshd log, you will need to activate syslogd (not launched by default).

Just do a docker exec gogs-container-name syslogd, you will then be able to get sshd log inside /var/log/messages.

Currently working on a way to print sshd logs inside docker logs, that why syslogd was not launched by default. I should had it for now. my bad.

@unknwon
Copy link
Member

unknwon commented Nov 4, 2015

@ygbillet can you dump your authorized_keys file here?

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

Actually with logging enabled it's better

Nov 4 17:57:52 d28c6f53a159 auth.info sshd[84]: Authentication refused: bad ownership or modes for directory /data/git

@0rax
Copy link
Contributor

0rax commented Nov 4, 2015

Quick fix would be chown -R git:git /data/git.

How did you launched the container itself, the command itself so I can try to reproduce this.

Will definitly add syslogd as a service for this purpose... While I try to find a way to output sshd logs to stdout !

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

Ok, so i change permissions for /data/git and it works. Not sure what caused the permissions errors.
I will try to get the error again

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

I can reproduce the error, here what i do

docker run --name=gogs-test-data --entrypoint /bin/true gogs/gogs
docker run -d --name=gogs-test --volumes-from gogs-test-data -p 10122:22 -p 10180:3000 gogs/gogs

@0rax
Copy link
Contributor

0rax commented Nov 4, 2015

That's weird, I cant reproduce on my own using a brand new instance of boot2docker.

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

Wait ! I may be skipped a step ! (i change my /.ssh/config for testing purpose ...)

I recreate an instance and try to get the same error again.
Sorry

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

Hmmm, get the same error again. Here what i do.

  1. Create a proper config on my laptop (generate ssh key, add to config)
  2. Create a data container for GOGS
  3. Create container for GOGS

I will try with boot2docker and on another server.

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

By the way, i correct the permission problem with chmod g-w /data/git.

@0rax
Copy link
Contributor

0rax commented Nov 4, 2015

Can you do a ls -lah of the /data directory.

So I can see how it differs and unsure the correct rights to the folder during gogs service setup phase.

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

Hmmm.

I try on another server and get different result :/ (permissions are ok).

Need more time to investigate the differences.
I'll keep you posted.

@0rax
Copy link
Contributor

0rax commented Nov 4, 2015 via email

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

Server 1 (not working as expected)

Docker Client:

Version:      1.8.3
API version:  1.20
Go version:   go1.4.2
Git commit:   f4bf5c7
Built:        Mon Oct 12 05:33:35 UTC 2015
OS/Arch:      linux/amd64

Docker Server:

Version:      1.8.3
API version:  1.20
Go version:   go1.4.2
Git commit:   f4bf5c7
Built:        Mon Oct 12 05:33:35 UTC 2015
OS/Arch:      linux/amd64

output of ls -lah /data

drwxr-x---    5 git      git         4.0K Nov  4 18:36 .
drwxr-xr-x   40 root     root        4.0K Nov  4 18:36 ..
drwxrwx---    3 git      git         4.0K Nov  4 18:36 git
drwxrwx---    5 git      git         4.0K Nov  4 18:36 gogs
drwxrwx---    2 git      git         4.0K Nov  4 18:36 ssh

Server 2 (working as expected)

Docker Client:

Version:      1.8.1
API version:  1.20
Go version:   go1.4.2
Git commit:   d12ea79
Built:        Thu Aug 13 02:28:37 UTC 2015
OS/Arch:      linux/amd64

Docker Server:

Version:      1.8.1
API version:  1.20
Go version:   go1.4.2
Git commit:   d12ea79
Built:        Thu Aug 13 02:28:37 UTC 2015
OS/Arch:      linux/amd64

output of ls -lah /data

drwxr-xr-x    5 git      git         4.0K Nov  4 18:35 .
drwxr-xr-x   40 root     root        4.0K Nov  4 18:35 ..
drwxr-xr-x    3 git      git         4.0K Nov  4 18:35 git
drwxr-xr-x    5 git      git         4.0K Nov  4 18:35 gogs
drwxr-xr-x    2 git      git         4.0K Nov  4 18:35 ssh

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

I upgrade Server 2 to docker 1.9.0 and it's working as expected.

@0rax
Copy link
Contributor

0rax commented Nov 4, 2015

Ok, so that's a weird behaviour, currently writing a fix to ensurce proper rights on this directory.

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

I cannot update Server 1 before 2 weeks because it's running critical apps.
I make a reminder and keep you posted about the issue after an upgrade do Docker 1.9.0.

@0rax
Copy link
Contributor

0rax commented Nov 4, 2015

In the same time, I will try to upgrade one of mine to 1.8.3 and publish a fix for it ! Thanks for your information. Will keep you informed when the fix is ready.

@ygbillet
Copy link
Author

ygbillet commented Nov 4, 2015

Thanks for your help.
Great job for creating this docker image

@unknwon
Copy link
Member

unknwon commented Nov 5, 2015

By merging #1898 to develop branch, this issue is claimed to be fixed, please help test again!

@ygbillet
Copy link
Author

ygbillet commented Nov 5, 2015

I tested the develop branch. Merge #1898 fix my issue. Thanks !

@ygbillet ygbillet closed this as completed Nov 5, 2015
@unknwon
Copy link
Member

unknwon commented Nov 5, 2015

Thanks your confirmation!

@unknwon unknwon removed the status: needs feedback Tell me more about it label Nov 5, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
📦 deployment Related to deployments
Projects
None yet
Development

No branches or pull requests

3 participants