|
| 1 | +# Git Shell Commands |
| 2 | +[heading__title]: |
| 3 | + #git-shell-commands |
| 4 | + "⬆ Top of this page" |
| 5 | + |
| 6 | + |
| 7 | +[`git-shell-commands`][master__get_shell_commands], contains a collection of scripts for Git Shell accounts. The following covers how to install this branch within a git-shell restricted account. |
| 8 | + |
| 9 | + |
| 10 | +## [![Repository Size][badge__master__git_shell_commands__size]][master__get_shell_commands] [![Open Issues][badge__issues__git_shell_commands]][issues__git_shell_commands] [![Open Pull Requests][badge__pull_requests__git_shell_commands]][pull_requests__git_shell_commands] [![Latest commits][badge__commits__git_shell_commands__master]][commits__git_shell_commands__master] |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +------ |
| 15 | + |
| 16 | + |
| 17 | +#### Table of Contents |
| 18 | + |
| 19 | + |
| 20 | +- [⬆ Top of ReadMe File][heading__title] |
| 21 | + |
| 22 | +- [:zap: Quick Start][heading__quick_start] |
| 23 | + |
| 24 | +- [🗒 Notes][notes] |
| 25 | + |
| 26 | +- [:copyright: License][heading__license] |
| 27 | + |
| 28 | + |
| 29 | +------ |
| 30 | + |
| 31 | + |
| 32 | +## Quick Start |
| 33 | +[heading__quick_start]: |
| 34 | + #quick-start |
| 35 | + "⚡ ...well as quick as it may get with things like this" |
| 36 | + |
| 37 | + |
| 38 | +**Bash Variables** |
| 39 | + |
| 40 | + |
| 41 | +```Bash |
| 42 | +_git_user='git-user' |
| 43 | +_git_group='devs' |
| 44 | +_git_home_base='/srv' |
| 45 | +_ssh_pub_key_path='/home/admin/client-keys/git-user/id_rsa.pub' |
| 46 | +_git_https_url='https://github.com/git-utilities/git-shell-commands.git' |
| 47 | +``` |
| 48 | + |
| 49 | + |
| 50 | +**Add Git shell** |
| 51 | + |
| 52 | + |
| 53 | +```Bash |
| 54 | +tee -a /etc/shells 1>/dev/null <<<"$(which git-shell)" |
| 55 | +``` |
| 56 | + |
| 57 | + |
| 58 | +**Add Git user** |
| 59 | + |
| 60 | + |
| 61 | +```Bash |
| 62 | +adduser\ |
| 63 | + --force-badname\ |
| 64 | + --system\ |
| 65 | + --disabled-password\ |
| 66 | + --gecos ''\ |
| 67 | + --shell "$(which git-shell)"\ |
| 68 | + --home "${_git_home_base,,}/${_git_user,,}"\ |
| 69 | + --ingroup "${_git_group}"\ |
| 70 | + "${_git_user}" |
| 71 | +``` |
| 72 | + |
| 73 | + |
| 74 | +**Clone to Git user's home directory** |
| 75 | + |
| 76 | + |
| 77 | +```Bash |
| 78 | +sudo su --login "${_git_user}" --shell /bin/bash <<EOF |
| 79 | +git clone --recurse-submodules "${_git_https_url}" |
| 80 | +EOF |
| 81 | +``` |
| 82 | + |
| 83 | + |
| 84 | +**Add SHH public key** |
| 85 | + |
| 86 | + |
| 87 | +```Bash |
| 88 | +sudo su --login "${_git_user}" --shell /bin/bash <<EOF |
| 89 | +mkdir .ssh |
| 90 | +tee -a .ssh/authorized_keys 1>/dev/null <<<"$(<"${_ssh_pub_key_path}")" |
| 91 | +chmod 600 .ssh/authorized_keys |
| 92 | +EOF |
| 93 | +``` |
| 94 | + |
| 95 | + |
| 96 | +**Set executable permissions** |
| 97 | + |
| 98 | + |
| 99 | +```Bash |
| 100 | +sudo su --login "${_git_user}" --shell /bin/bash <<'EOF' |
| 101 | +while IFS= read -r -d '' _path; do |
| 102 | + _file_type="$(file --brief --mime-type "${_path}")" |
| 103 | + if [[ "${_file_type}" == 'text/x-shellscript' ]]; then |
| 104 | + chmod --verbose u+x "${_path}" |
| 105 | + fi |
| 106 | +done < <(find 'git-shell-commands/' -type f -not -path '*.*' -print0) |
| 107 | +EOF |
| 108 | +``` |
| 109 | + |
| 110 | + |
| 111 | +___ |
| 112 | + |
| 113 | + |
| 114 | +## Notes |
| 115 | +[notes]: |
| 116 | + #notes |
| 117 | + "🗒 Additional notes and links that may be worth clicking in the future" |
| 118 | + |
| 119 | + |
| 120 | +To disable `push` and `pull` remove the Git tracking files and directories |
| 121 | + |
| 122 | + |
| 123 | +```Bash |
| 124 | +sudo su --login "${_git_user}" --shell /bin/bash <<'EOF' |
| 125 | +find "./git-shell-commands" -type d -name '.git' -exec bash -c 'rm -r "$0"' {} |
| 126 | +find "./git-shell-commands" -type f -name '.git' -exec bash -c 'rm "$0"' {} |
| 127 | +find "./git-shell-commands" -type f -name '.gitmodules' -exec bash -c 'rm "$0"' {} |
| 128 | +EOF |
| 129 | +``` |
| 130 | + |
| 131 | + |
| 132 | +To disable interactive logins |
| 133 | + |
| 134 | +```Bash |
| 135 | +sudo su --login "${_git_user}" --shell /bin/bash <<EOC |
| 136 | +tee 'git-shell-commands/no-interactive-login' 1>/dev/null <<'EOF' |
| 137 | +#!/usr/bin/env bash |
| 138 | +printf 'Hi %s, you have successfully authenticated!\n' "${USER}" |
| 139 | +printf 'However, there is not an interactive shell here.\n' |
| 140 | +exit 128 |
| 141 | +EOF |
| 142 | +
|
| 143 | +chmod u+x 'git-shell-commands/no-interactive-login' |
| 144 | +EOC |
| 145 | +``` |
| 146 | + |
| 147 | + |
| 148 | +To list scripts available to Git user |
| 149 | + |
| 150 | + |
| 151 | +```Bash |
| 152 | +ssh "${_git_user}"@localhost -i "${_ssh_pub_key_path}" list --help |
| 153 | +``` |
| 154 | + |
| 155 | + |
| 156 | +**Example client `~/.ssh/config`** SSH configurations such as the following may be useful in making SSH/Git commands more terse |
| 157 | + |
| 158 | + |
| 159 | +```sshd_config |
| 160 | +Host git-user |
| 161 | + IdentitiesOnly yes |
| 162 | + IdentityFile ~/.ssh/id_rsa |
| 163 | + HostName 192.168.0.2 |
| 164 | + User git-user |
| 165 | +``` |
| 166 | + |
| 167 | + |
| 168 | +Each script should have documentation on arguments and usage accessible via `--help` or `-h` options |
| 169 | + |
| 170 | + |
| 171 | +```Bash |
| 172 | +ssh git-user git-init --help |
| 173 | +``` |
| 174 | + |
| 175 | + |
| 176 | +Pull Requests are welcomed! Check the _`Community`_ section for development tips and code of conduct relevant updates. |
| 177 | + |
| 178 | + |
| 179 | +___ |
| 180 | + |
| 181 | + |
| 182 | +## License |
| 183 | +[heading__license]: |
| 184 | + #license |
| 185 | + "© Legal bits of Open Source software" |
| 186 | + |
| 187 | + |
| 188 | +``` |
| 189 | +Git Shell Commands submodule quick start documentation |
| 190 | +Copyright (C) 2019 S0AndS0 |
| 191 | +
|
| 192 | +This program is free software: you can redistribute it and/or modify |
| 193 | +it under the terms of the GNU Affero General Public License as published |
| 194 | +by the Free Software Foundation; version 3 of the License. |
| 195 | +
|
| 196 | +This program is distributed in the hope that it will be useful, |
| 197 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 198 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 199 | +GNU Affero General Public License for more details. |
| 200 | +
|
| 201 | +You should have received a copy of the GNU Affero General Public License |
| 202 | +along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 203 | +``` |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | +[badge__travis_ci__git_shell_commands]: |
| 208 | + https://img.shields.io/travis/git-utilities/git-shell-commands/example.svg |
| 209 | + |
| 210 | +[travis_ci__git_shell_commands]: |
| 211 | + https://travis-ci.com/git-utilities/git-shell-commands |
| 212 | + "🛠 Automated tests and build logs" |
| 213 | + |
| 214 | + |
| 215 | +[branch_example__example_usage]: |
| 216 | + https://github.com/git-utilities/git-shell-commands/blob/example/example-usage.sh |
| 217 | + "Bash script that shows some ways of utilizing code from the master branch of this repository" |
| 218 | + |
| 219 | + |
| 220 | +[badge__commits__git_shell_commands__master]: |
| 221 | + https://img.shields.io/github/last-commit/git-utilities/git-shell-commands/master.svg |
| 222 | + |
| 223 | +[commits__git_shell_commands__master]: |
| 224 | + https://github.com/git-utilities/git-shell-commands/commits/master |
| 225 | + "📝 History of changes on this branch" |
| 226 | + |
| 227 | + |
| 228 | +[git_shell_commands__community]: |
| 229 | + https://github.com/git-utilities/git-shell-commands/community |
| 230 | + "🌱 Dedicated to functioning code" |
| 231 | + |
| 232 | + |
| 233 | +[git_shell_commands__example_branch]: |
| 234 | + https://github.com/git-utilities/git-shell-commands/tree/example |
| 235 | + "If it lurches, it lives" |
| 236 | + |
| 237 | + |
| 238 | +[badge__issues__git_shell_commands]: |
| 239 | + https://img.shields.io/github/issues/git-utilities/git-shell-commands.svg |
| 240 | + |
| 241 | +[issues__git_shell_commands]: |
| 242 | + https://github.com/git-utilities/git-shell-commands/issues |
| 243 | + "☢ Search for and _bump_ existing issues or open new issues for project maintainer to address." |
| 244 | + |
| 245 | + |
| 246 | +[badge__pull_requests__git_shell_commands]: |
| 247 | + https://img.shields.io/github/issues-pr/git-utilities/git-shell-commands.svg |
| 248 | + |
| 249 | +[pull_requests__git_shell_commands]: |
| 250 | + https://github.com/git-utilities/git-shell-commands/pulls |
| 251 | + "🏗 Pull Request friendly, though please check the Community guidelines" |
| 252 | + |
| 253 | + |
| 254 | +[badge__master__git_shell_commands__size]: |
| 255 | + https://img.shields.io/github/languages/code-size/git-utilities/git-shell-commands.svg |
| 256 | + |
| 257 | +[master__get_shell_commands]: |
| 258 | + https://github.com/git-utilities/git-shell-commands/ |
| 259 | + "⌨ Project source code!" |
0 commit comments