Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

SSH host connection assumption #114

@alexrussell

Description

@alexrussell

As per the discussion on this thread, this is an issue just putting the things learnt on the radar here.

The general thing is that if using a 'Remote URL'-type repository and that host has never been connected to by the user that runs the cron job (which may not be the same as the user that the webserver runs as, just to be extra confusing) then any build will likely fail due to the "unable to verify the authenticity of this host" message (and expectation of input - use needs to type "yes" at the prompt) that comes from SSH connecting to a host that is not listed in ~/.ssh/known_hosts

I originally suggested that at the least the installation insturction or the "new/edit project" page should contain a warning that you'll need to go in and connect to the host manually from the user, but to be honest that's unacceptable and I found a better way.

The better way would be to, upon adding (or editing if the clone URL changes) a project that is a 'Remote URL'-type project, the webserver should quickly attempt to SSH to the host to run an arbitrary command using the -oScrictHostKeyChecking=no command line flag. This should connect to the host, ignore the "add this to the list?" question and actually silently add the host to the list. Some/most git servers don't actually allow an interactive TTY (so the command may fail), but simply having a connection should be enough to achieve what we want this.

It may also be worth saying in the installation instructions that the webserver and the cron job must run as the same user. This is because if the website initially does this connection the host will go into that user's ~/.ssh/known_hosts file, but when the cron job comes to run the builds, PHP runs as that user and so SSH will check their ~/.ssh/known_hosts file. Maybe this isn't a big deal, but the installation instructions are fairly loose as-is, and I worry that some people will run the website as the standard www-data user (default with Apache + PHP and Nginx + PHP-FPM I think) but the cron job as their local user. I haven't because I didn't want to have to deal with possible file permission issues (and didn't want to chmod 777 all the things!) so my setup runs both as www-data.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions