{"id":627,"date":"2021-07-23T12:34:18","date_gmt":"2021-07-23T12:34:18","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/guide-to-git-for-system-administrators\/"},"modified":"2021-07-23T12:34:18","modified_gmt":"2021-07-23T12:34:18","slug":"guide-to-git-for-system-administrators","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/guide-to-git-for-system-administrators\/","title":{"rendered":"Guide to Git\u2122 &#8211; For System Administrators"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>The <em>Git Version Control<\/em> feature includes several changes from the Git\u2122 default configuration. Additionally, we impose certain restrictions on cPanel-hosted repositories. This document also includes information that may assist you in troubleshooting cPanel users\u2019 issues.<\/p>\n<h2 id=\"restrictions\">Restrictions<\/h2>\n<p>This feature imposes the following restrictions on cPanel-hosted repositories:<\/p>\n<ul>\n<li>\n<p>Currently, we only support a single remote repository for each local repository. To use multiple remote repositories, users must <strong>only<\/strong> use the command line.<\/p>\n<\/li>\n<li>\n<p>Users <strong>cannot<\/strong> include whitespace or the following characters in repository paths: <code> * | \" ' &lt; &gt; & @ ` $ { } [ ] ( ) ; ? : = % #<\/code><\/p>\n<\/li>\n<li>\n<p>Users cannot use this feature to create, delete, or view repositories in the following cPanel-controlled directories:<\/p>\n<ul>\n<li><code>.cpanel<\/code><\/li>\n<li><code>.cphorde<\/code><\/li>\n<li><code>.htpasswds<\/code><\/li>\n<li><code>.ssh<\/code><\/li>\n<li><code>.trash<\/code><\/li>\n<li><code>access-logs<\/code><\/li>\n<li><code>cgi-bin<\/code><\/li>\n<li><code>etc<\/code><\/li>\n<li><code>logs<\/code><\/li>\n<li><code>perl5<\/code><\/li>\n<li><code>mail<\/code><\/li>\n<li><code>spamassassin<\/code><\/li>\n<li><code>ssl<\/code><\/li>\n<li><code>tmp<\/code><\/li>\n<li><code>var<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>cPanel users <strong>cannot<\/strong> use the <code>.<\/code> or <code>..<\/code> directory references when they enter the repository path in the interface.<\/p>\n<\/p><\/div>\n<\/div>\n<h2 id=\"configuration-changes\">Configuration changes<\/h2>\n<p>This feature alters the following configuration settings:<\/p>\n<ul>\n<li><code>gc.auto<\/code> \u2014 We have disabled Git\u2019s garbage-collection setting for all cPanel-managed repositories.<\/li>\n<li><code>receive.denyCurrentBranch<\/code> \u2014 The system automatically sets this setting in each cPanel-managed repository\u2019s configuration file to the <code>updateInstead<\/code> option.\n<ul>\n<li>The system ensures this configuration each time that you create a new repository via the <code>VersionControl::create<\/code> function.<\/li>\n<li>The <code>updateInstead<\/code> option causes Git to automatically update the working tree whenever you push changes into the current branch.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>This feature uses a cPanel-provided Git RPM. The Git RPM symlinks Git binaries in the <code>\/usr\/local\/cpanel\/3rdparty\/bin\/<\/code> directory to the <code>\/usr\/local\/cpanel\/3rdparty\/lib\/path-bin\/<\/code> directory, to cause them to exist in the user\u2019s default path.<\/p>\n<h2 id=\"deployment\">Deployment<\/h2>\n<div class=\"callout callout-warning\">\n<div class=\"callout-heading\">Important:<\/div>\n<div class=\"callout-content\">\n<p>We <strong>strongly<\/strong> recommend that you only deploy changes from a remote repository or a clone of it on your local computer. You should <strong>not<\/strong> directly change the cPanel-managed repository\u2019s contents.<br \/>\nFor more information about our suggested deployment configuration and how to set it up, read our Guide to Git &#8211; How to Set Up Deployment documentation.<\/p>\n<\/p><\/div>\n<\/div>\n<p>Before deployment, repositories <strong>must<\/strong> meet the following requirements:<\/p>\n<ul>\n<li>A valid checked-in <code>.cpanel.yml<\/code> file in the top-level directory.<\/li>\n<li>One or more local or remote branches.<\/li>\n<li>A clean working tree.<\/li>\n<\/ul>\n<p>If a repository does <strong>not<\/strong> meet these requirements, the system will <strong>not<\/strong> display deployment information. Also, it will disable deployment functionality.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>The system adds a <code>post-receive<\/code> hook to all cPanel-managed repositories.\n<ul>\n<li>This hook will automatically run any commands in the .cpanel.yml file whenever changes deploy.<\/li>\n<li>For more information, read Git\u2019s githooks documentation.<\/li>\n<\/ul>\n<\/li>\n<li>The system stores deployment process-related historical data in an SQLite database within the <code>\/home\/user\/.cpanel\/datastore\/vc_deploy.sqlite<\/code> file, where <code>user<\/code> represents the cPanel account name.<\/li>\n<\/ul><\/div>\n<\/div>\n<p>For instructions to set up deployment, read our Guide to Git &#8211; How to Set Up Deployment documentation.<\/p>\n<p>For more information about deployment, read our Guide to Git &#8211; Deployment documentation.<\/p>\n<h2 id=\"ssh-host-key-verification\">SSH host key verification<\/h2>\n<p>When users clone a repository via SSH, the system will automatically check for the remote server\u2019s public SSH key in the <code>\/home\/user\/.ssh\/known_hosts<\/code> file, where <code>user<\/code> represents the account\u2019s username.<\/p>\n<ul>\n<li>If the remote host is <strong>not<\/strong> registered with the system, the system will prompt the user to accept it. Then, it will add it to the <code>\/home\/user\/.ssh\/known_hosts<\/code> file, where <code>user<\/code> represents the account\u2019s username.<\/li>\n<li>If the remote host is already registered, the system will display a confirmation message.<\/li>\n<li>If the remote host\u2019s public key has changed, the system will display a warning.\n<ul>\n<li>For third-party remote hosts, check for announcements about public key updates. Most companies that host repositories make announcements about these changes.<\/li>\n<li>For remote hosts that you control, consider whether recent events on your system have caused changes to the public key.<\/li>\n<li>For any private repositories, make <strong>certain<\/strong> that you have performed the steps in our Guide to Git &#8211; Set Up Access to Private Repositories documentation.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>The system also performs these checks each time that a user updates the repository\u2019s information or attempts to pull changes from the repository via the cPanel interface.<\/p>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n<p>If you cannot verify the validity of the change, exercise caution, especially if the repository includes sensitive content. An altered SSH key may indicate a Man-in-the-Middle attack.<\/p>\n<\/p><\/div>\n<\/div>\n<p>In order for users to see these warnings, you <strong>must<\/strong> enable the <em>Enable strict SSH host key checking<\/em> setting in the <em>Security<\/em> section of WHM\u2019s <em>Tweak Settings<\/em> interface (<em>WHM &gt;&gt; Home &gt;&gt; Server Configuration &gt;&gt; Tweak Settings<\/em>).<\/p>\n<h2 id=\"troubleshooting\">Troubleshooting<\/h2>\n<p>If cPanel users experience problems with their repositories, use the following steps to troubleshoot them.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>This feature logs messages and errors to the following locations:<\/p>\n<ul>\n<li><code>\/usr\/local\/cpanel\/logs\/error_log<\/code> \u2014 Errors and stack traces.<\/li>\n<li><code>\/home\/username\/.cpanel\/logs\/user_task_runner.log<\/code> \u2014 Queue-related items.<\/li>\n<li><code>\/home\/username\/.cpanel\/logs\/vc_TIMESTAMP_git_create.log<\/code> \u2014 Creation-related issues, where <code>TIMESTAMP<\/code> represents the time of the operation.<\/li>\n<li><code>\/home\/username\/.cpanel\/logs\/vc_TIMESTAMP_git_deploy.log<\/code> \u2014 Deployment-related issues, where <code>TIMESTAMP<\/code> represents the time of the operation.<\/li>\n<\/ul><\/div>\n<\/div>\n<h3 id=\"missing-repositories\">Missing repositories<\/h3>\n<p>If repositories exist on the command line but do not display in cPanel\u2019s <em>Git Version Control<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control<\/em>), the issue may occur because the feature ignores repositories that users created on the command line.<\/p>\n<h3 id=\"missing-branches\">Missing branches<\/h3>\n<p>If the expected list of branches does not display in cPanel\u2019s <em>Git Version Control<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control<\/em>), the issue may be due to the following causes:<\/p>\n<ul>\n<li>The branches exist in the copies of the repository on your local computer or remote repository host, but do <strong>not<\/strong> exist within the cPanel-managed repository.<\/li>\n<li>The repository is a bare repository. Bare repositories do not include branches.<\/li>\n<\/ul>\n<h3 id=\"cloned-repositories\">Cloned repositories<\/h3>\n<p>While the system clones the remote repository, cPanel\u2019s <em>Git Version Control<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control<\/em>) will <strong>only<\/strong> display the repository name and path.<\/p>\n<p>When users clone a repository, the system clones it via a queued process that runs as that cPanel user. Clones can require a large amount of time, which depends on the size of the repository to clone.<\/p>\n<ul>\n<li>\n<p>While the clone process runs, cPanel\u2019s <em>Git Version Control<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control<\/em>) will <strong>only<\/strong> display the repository name, repository path, and a progress indicator. Additionally, the system will temporarily disable most of the management functionality for that repository.<\/p>\n<\/li>\n<li>\n<p>The <code>process_user_tasks<\/code> binary runs as the cPanel user to process each clone, and the queue for each user exists in their <code>.cpanel\/user_tasks\/<\/code> directory. To resolve issues with clones, stop the process and delete the directory.<\/p>\n<\/li>\n<\/ul>\n<h2 id=\"ssh-access\">SSH access<\/h2>\n<p>If users experience problems with SSH access, ensure that the server and the users\u2019 accounts include the following settings and configurations:<\/p>\n<ul>\n<li>\n<p>Port 22 is publicly accessible. If the server uses a nonstandard Git port, use the <code>ssh -p port<\/code> command, where <code>port<\/code> represents the port number, to SSH in to the account.<\/p>\n<\/li>\n<li>\n<p>The <em>Shell Access<\/em> setting is enabled for the account in WHM\u2019s <em>Modify an Account<\/em> interface (<em>WHM &gt;&gt; Home &gt;&gt; Account Functions &gt;&gt; Modify an Account<\/em>).<\/p>\n<\/li>\n<li>\n<p>The <em>SSH Access &#038; Terminal<\/em> feature is enabled for the user\u2019s feature list in WHM\u2019s <em>Feature Manager<\/em> interface (<em>WHM &gt;&gt; Home &gt;&gt; Packages &gt;&gt; Feature Manager<\/em>).<\/p>\n<\/li>\n<\/ul>\n<p>If none of these solutions fix the issue, ensure that the user correctly configured their <strong>public<\/strong> SSH keys in cPanel\u2019s <em>SSH Access<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Security &gt;&gt; SSH Access<\/em>).<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>If a user attempts to clone a remote repository via SSH and receives errors about a refused connection, perform one of the following actions:<\/p>\n<ul>\n<li>Clone the repository via HTTPS in a read-only configuration.<\/li>\n<li>Register the cPanel account\u2019s SSH key pair with the remote repository\u2019s host as a deployment key.<\/li>\n<\/ul><\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview The Git Version Control feature includes several changes from the Git\u2122 default configuration. Additionally, we impose certain restrictions on cPanel-hosted repositories. This document also includes information that may assist you in troubleshooting cPanel users\u2019 issues. Restrictions This feature imposes the following restrictions on cPanel-hosted repositories: Currently, we only support a single remote repository for &hellip;<\/p>\n","protected":false},"author":1,"featured_media":628,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/627"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=627"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/627\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/628"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}