Restricted Permissions on Host SSH Keys causes a 500 on Instance configuration
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Work on this issue](https://contributors.gitlab.com/manage-issue?action=work&projectId=278964&issueIid=497868) - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=497868) </details> <!--IssueSummary end--> ### Summary If an instance's SSH Keys are restricted (600) so that the GitLab service cannot access them accessing the instance configuration page (`/help/instance_configuration`) will result in a 500. ``` Permission denied @ rb_sysopen - /etc/ssh/ssh_host_ecdsa_key.pub ``` ### Steps to reproduce 1. Set SSH Host keys to 600 (`/etc/ssh/ssh_host_ecdsa_key.pub`) 2. Access Instance Configuration Page `/help/instance_configuration` ### What is the current *bug* behavior? Page returns a 500 ``` "exception.class": "ActionView::Template::Error", "exception.message": "Permission denied @ rb_sysopen - /etc/ssh/ssh_host_ecdsa_key.pub", ``` Backtrace: ``` "app/models/instance_configuration.rb:168:in `read'", "app/models/instance_configuration.rb:168:in `ssh_algorithm_file_content'", "app/models/instance_configuration.rb:156:in `ssh_algorithm_hashes'", "app/models/instance_configuration.rb:26:in `block in ssh_algorithms_hashes'", "app/models/instance_configuration.rb:26:in `map'", "app/models/instance_configuration.rb:26:in `ssh_algorithms_hashes'", "app/models/instance_configuration.rb:13:in `block in settings'", ``` ### What is the expected *correct* behavior? Warning that SSH Keys couldn't be read ### Possible fixes I think this might be as simple as adding a rescue block to the configuration model to replace the output with a unable to read / permissions warning. https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/instance_configuration.rb [Internal ZD](https://gitlab.zendesk.com/agent/tickets/573342)
issue