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

[docker] simplify the log handling of sshd #6529

Merged
merged 3 commits into from
Apr 17, 2019

Conversation

das7pad
Copy link
Contributor

@das7pad das7pad commented Apr 6, 2019

By default sshd forwards any log messages to the syslog. As docker containers do not have access to the syslog daemon on the docker-host, a new daemon was added into the container gogs/gogs#1898.

This indirection is actually not needed. We can get the log messages directly into the docker container log.

Using the -e flag for sshd forwards the output to stderr and with a stream redirect we can get the output to stdout.

Startup and invalid auth before and after applying this patch:

# docker logs --timestamps gitea_container_syslogd | grep -e ' Server listening' -e ' user'
2019-04-06T18:15:29.117905987Z Apr  6 18:15:29 sshd[72]: Server listening on :: port 22.
2019-04-06T18:15:29.117945956Z Apr  6 18:15:29 sshd[72]: Server listening on 0.0.0.0 port 22.
2019-04-06T18:18:43.162626992Z Apr  6 18:18:43 sshd[84]: Connection closed by invalid user nobody 172.x.x.x port 39836 [preauth]

# docker logs --timestamps gitea_container_direct | grep -e ' Server listening' -e ' user'
2019-04-06T18:30:01.538122152Z Server listening on :: port 22.
2019-04-06T18:30:01.538175245Z Server listening on 0.0.0.0 port 22.
2019-04-06T18:30:41.454457822Z Connection closed by invalid user nobody 172.x.x.x port 41812 [preauth]

The sshd flag `-e` instructs sshd to output any logs to stderr instead
 of the syslog. Redirect this output to stdout then.

Signed-off-by: Jakob Ackermann <das7pad@outlook.com>
@codecov-io
Copy link

codecov-io commented Apr 6, 2019

Codecov Report

Merging #6529 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6529      +/-   ##
==========================================
+ Coverage   40.54%   40.54%   +<.01%     
==========================================
  Files         406      406              
  Lines       54501    54501              
==========================================
+ Hits        22095    22098       +3     
+ Misses      29370    29367       -3     
  Partials     3036     3036
Impacted Files Coverage Δ
modules/log/event.go 65.98% <0%> (+1.52%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6821a32...1eddaf1. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 6, 2019
@techknowlogick techknowlogick added the type/enhancement An improvement of existing functionality label Apr 17, 2019
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 17, 2019
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 17, 2019
@techknowlogick techknowlogick merged commit 62b3596 into go-gitea:master Apr 17, 2019
@das7pad das7pad deleted the misc/simplify-sshd-logging branch April 17, 2019 07:49
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants