Joey Armstrong | 56334fc | 2023-01-15 22:53:19 -0500 | [diff] [blame] | 1 | Gerrit SSH Access |
| 2 | ################# |
| 3 | |
| 4 | - `Gerrit Login <https://gerrit.opencord.org/login/%2Fq%2Fstatus%3Aopen%2B-is%3Awip>`_ |
| 5 | |
| 6 | Generate an :ref:`SSH Key <gerrit-user-account>` for access |
| 7 | ============================================================ |
| 8 | |
| 9 | .. sourcecode:: shell |
| 10 | |
| 11 | $ ssh-keygen -t ed25519 -f id_gerrit -C 'tux@opennetworking.org' |
| 12 | |
| 13 | - Login and configure gerrit |
| 14 | |
| 15 | - Verify your ssh connection (manual/explicit args) |
Joey Armstrong | b8a1e05 | 2023-08-07 09:32:53 -0400 | [diff] [blame] | 16 | - ssh -T -p 29418 -i ~/.ssh/id_gerrit tux@gerrit.opencord.org |
Joey Armstrong | 56334fc | 2023-01-15 22:53:19 -0500 | [diff] [blame] | 17 | - -T # disable pseudo terminal access, simple verify |
| 18 | - -p(port) |
| 19 | - -i(dentity) # ssh key |
| 20 | - Expect to see:: |
| 21 | \*\*\*\* Welcome to Gerrit Code Review \*\*\*\* |
| 22 | |
| 23 | Hi tux, you have successfully connected over SSH. |
| 24 | |
| 25 | Unfortunately, interactive shells are disabled. |
| 26 | |
| 27 | |
| 28 | Load your ssh key(s) to prompt for a passprase once |
| 29 | =================================================== |
| 30 | |
| 31 | .. sourcecode:: shell |
| 32 | |
| 33 | # ssh-add will prompt for the passphrase for your key. |
| 34 | # This is a one-time operation per login session. |
| 35 | $ ssh-add ~/.ssh/id_gerrit |
| 36 | $ ssh-add -l |
| 37 | |
| 38 | Create ~/.ssh/config to simplify your connections |
| 39 | ================================================= |
| 40 | .. sourcecode:: shell |
| 41 | |
| 42 | FILE: ~/.ssh/config |
Joey Armstrong | b8a1e05 | 2023-08-07 09:32:53 -0400 | [diff] [blame] | 43 | # ----------------------------------------------------------------------- |
| 44 | # AddKeysToAgent yes auto ssh-add key for reuse this login session. |
Joey Armstrong | 56334fc | 2023-01-15 22:53:19 -0500 | [diff] [blame] | 45 | # IdentitiesOnly yes only use identity provided, no fallback |
Joey Armstrong | b8a1e05 | 2023-08-07 09:32:53 -0400 | [diff] [blame] | 46 | # ----------------------------------------------------------------------- |
Joey Armstrong | 56334fc | 2023-01-15 22:53:19 -0500 | [diff] [blame] | 47 | |
| 48 | Host github.com |
| 49 | IdentityFile ~/.ssh/github.com/id_ed25519 |
| 50 | IdentitiesOnly yes |
Joey Armstrong | b8a1e05 | 2023-08-07 09:32:53 -0400 | [diff] [blame] | 51 | AddKeysToAgent yes |
Joey Armstrong | 56334fc | 2023-01-15 22:53:19 -0500 | [diff] [blame] | 52 | # (default) Port 22 |
| 53 | User tux |
| 54 | |
| 55 | Host gerrit.opencord.org |
| 56 | Hostname gerrit.opencord.org |
| 57 | IdentityFile ~/.ssh/gerrit.opencord.org/id_ed25519 |
| 58 | IdentitiesOnly yes |
Joey Armstrong | b8a1e05 | 2023-08-07 09:32:53 -0400 | [diff] [blame] | 59 | AddKeysToAgent yes |
Joey Armstrong | 56334fc | 2023-01-15 22:53:19 -0500 | [diff] [blame] | 60 | Port 29418 |
| 61 | User tux@opennetworking.org |
| 62 | |
| 63 | With ~/.ssh/config setup simply connect to the target machine: |
| 64 | ============================================================== |
| 65 | - ssh gerrit.opencord.org |
| 66 | |
| 67 | |
| 68 | Secure permissions on ~/.ssh |
| 69 | ============================ |
| 70 | |
| 71 | .. sourcecode:: shell |
| 72 | |
| 73 | $ chown -R {my_login}:{my_login} ~/.ssh |
| 74 | $ chmod -R ~/.ssh u+rwx,og-rwx |
| 75 | $ find ~/.ssh -type d -print0 | xargs -0 chmod u=rwx |
| 76 | $ find ~/.ssh -type f -print0 | xargs -0 chmod u=r |
| 77 | $ find ~/.ssh -name '*.pub' -type f -print0 | xargs -0 chmod u=rw |
| 78 | $ chmod u=rw ~/.ssh/config ~/.ssh/known_hosts* ~/.ssh/authorized_keys |
| 79 | |
| 80 | Debugging connection problems |
| 81 | =============================== |
| 82 | - ssh [-v | -vv | -vvv ] to enable connection debugging. |
| 83 | - For conneciton problems be explicit when specifying arguments: |
| 84 | - ssh -p(ort) -i(dentity) {user}@{host} |
| 85 | - Use ssh-add -D to clear your keyring and force passphrase prompting. |