You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

command-line.en-us.md 17 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. ---
  2. date: "2017-01-01T16:00:00+02:00"
  3. title: "Usage: Command Line"
  4. slug: "command-line"
  5. weight: 10
  6. toc: true
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "usage"
  11. name: "Command Line"
  12. weight: 10
  13. identifier: "command-line"
  14. ---
  15. ## Command Line
  16. ### Usage
  17. `gitea [global options] command [command or global options] [arguments...]`
  18. ### Global options
  19. All global options can be placed at the command level.
  20. - `--help`, `-h`: Show help text and exit. Optional.
  21. - `--version`, `-v`: Show version and exit. Optional. (example: `Gitea version 1.1.0+218-g7b907ed built with: bindata, sqlite`).
  22. - `--custom-path path`, `-C path`: Location of the Gitea custom folder. Optional. (default: `AppWorkPath`/custom or `$GITEA_CUSTOM`).
  23. - `--config path`, `-c path`: Gitea configuration file path. Optional. (default: `custom`/conf/app.ini).
  24. - `--work-path path`, `-w path`: Gitea `AppWorkPath`. Optional. (default: LOCATION_OF_GITEA_BINARY or `$GITEA_WORK_DIR`)
  25. NB: The defaults custom-path, config and work-path can also be
  26. changed at build time (if preferred).
  27. ### Commands
  28. #### web
  29. Starts the server:
  30. - Options:
  31. - `--port number`, `-p number`: Port number. Optional. (default: 3000). Overrides configuration file.
  32. - `--pid path`, `-P path`: Pidfile path. Optional.
  33. - Examples:
  34. - `gitea web`
  35. - `gitea web --port 80`
  36. - `gitea web --config /etc/gitea.ini --pid /var/run/gitea.pid`
  37. - Notes:
  38. - Gitea should not be run as root. To bind to a port below 1000, you can use setcap on
  39. Linux: `sudo setcap 'cap_net_bind_service=+ep' /path/to/gitea`. This will need to be
  40. redone every time you update Gitea.
  41. #### admin
  42. Admin operations:
  43. - Commands:
  44. - `create-user`
  45. - Options:
  46. - `--name value`: Username. Required. As of gitea 1.9.0, use the `--username` flag instead.
  47. - `--username value`: Username. Required. New in gitea 1.9.0.
  48. - `--password value`: Password. Required.
  49. - `--email value`: Email. Required.
  50. - `--admin`: If provided, this makes the user an admin. Optional.
  51. - `--access-token`: If provided, an access token will be created for the user. Optional. (default: false).
  52. - `--must-change-password`: If provided, the created user will be required to choose a newer password after
  53. the initial login. Optional. (default: true).
  54. - ``--random-password``: If provided, a randomly generated password will be used as the password of
  55. the created user. The value of `--password` will be discarded. Optional.
  56. - `--random-password-length`: If provided, it will be used to configure the length of the randomly
  57. generated password. Optional. (default: 12)
  58. - Examples:
  59. - `gitea admin create-user --username myname --password asecurepassword --email me@example.com`
  60. - `change-password`
  61. - Options:
  62. - `--username value`, `-u value`: Username. Required.
  63. - `--password value`, `-p value`: New password. Required.
  64. - Examples:
  65. - `gitea admin change-password --username myname --password asecurepassword`
  66. - `regenerate`
  67. - Options:
  68. - `hooks`: Regenerate git-hooks for all repositories
  69. - `keys`: Regenerate authorized_keys file
  70. - Examples:
  71. - `gitea admin regenerate hooks`
  72. - `gitea admin regenerate keys`
  73. - `auth`:
  74. - `list`:
  75. - Description: lists all external authentication sources that exist
  76. - Examples:
  77. - `gitea admin auth list`
  78. - `delete`:
  79. - Options:
  80. - `--id`: ID of source to be deleted. Required.
  81. - Examples:
  82. - `gitea admin auth delete --id 1`
  83. - `add-oauth`:
  84. - Options:
  85. - `--name`: Application Name.
  86. - `--provider`: OAuth2 Provider.
  87. - `--key`: Client ID (Key).
  88. - `--secret`: Client Secret.
  89. - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
  90. - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
  91. - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
  92. - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
  93. - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
  94. - `--custom-email-url`: Use a custom Email URL (option for GitHub).
  95. - Examples:
  96. - `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE`
  97. - `update-oauth`:
  98. - Options:
  99. - `--id`: ID of source to be updated. Required.
  100. - `--name`: Application Name.
  101. - `--provider`: OAuth2 Provider.
  102. - `--key`: Client ID (Key).
  103. - `--secret`: Client Secret.
  104. - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
  105. - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
  106. - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
  107. - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
  108. - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
  109. - `--custom-email-url`: Use a custom Email URL (option for GitHub).
  110. - Examples:
  111. - `gitea admin auth update-oauth --id 1 --name external-github-updated`
  112. - `add-ldap`: Add new LDAP (via Bind DN) authentication source
  113. - Options:
  114. - `--name value`: Authentication name. Required.
  115. - `--not-active`: Deactivate the authentication source.
  116. - `--security-protocol value`: Security protocol name. Required.
  117. - `--skip-tls-verify`: Disable TLS verification.
  118. - `--host value`: The address where the LDAP server can be reached. Required.
  119. - `--port value`: The port to use when connecting to the LDAP server. Required.
  120. - `--user-search-base value`: The LDAP base at which user accounts will be searched for. Required.
  121. - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. Required.
  122. - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
  123. - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
  124. - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
  125. - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
  126. - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required.
  127. - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
  128. - `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user.
  129. - `--bind-password value`: The password for the Bind DN, if any.
  130. - `--attributes-in-bind`: Fetch attributes in bind DN context.
  131. - `--synchronize-users`: Enable user synchronization.
  132. - `--page-size value`: Search page size.
  133. - Examples:
  134. - `gitea admin auth add-ldap --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-search-base "ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(uid=%s))" --email-attribute mail`
  135. - `update-ldap`: Update existing LDAP (via Bind DN) authentication source
  136. - Options:
  137. - `--id value`: ID of authentication source. Required.
  138. - `--name value`: Authentication name.
  139. - `--not-active`: Deactivate the authentication source.
  140. - `--security-protocol value`: Security protocol name.
  141. - `--skip-tls-verify`: Disable TLS verification.
  142. - `--host value`: The address where the LDAP server can be reached.
  143. - `--port value`: The port to use when connecting to the LDAP server.
  144. - `--user-search-base value`: The LDAP base at which user accounts will be searched for.
  145. - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate.
  146. - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
  147. - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
  148. - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
  149. - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
  150. - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address.
  151. - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
  152. - `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user.
  153. - `--bind-password value`: The password for the Bind DN, if any.
  154. - `--attributes-in-bind`: Fetch attributes in bind DN context.
  155. - `--synchronize-users`: Enable user synchronization.
  156. - `--page-size value`: Search page size.
  157. - Examples:
  158. - `gitea admin auth update-ldap --id 1 --name "my ldap auth source"`
  159. - `gitea admin auth update-ldap --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn`
  160. - `add-ldap-simple`: Add new LDAP (simple auth) authentication source
  161. - Options:
  162. - `--name value`: Authentication name. Required.
  163. - `--not-active`: Deactivate the authentication source.
  164. - `--security-protocol value`: Security protocol name. Required.
  165. - `--skip-tls-verify`: Disable TLS verification.
  166. - `--host value`: The address where the LDAP server can be reached. Required.
  167. - `--port value`: The port to use when connecting to the LDAP server. Required.
  168. - `--user-search-base value`: The LDAP base at which user accounts will be searched for.
  169. - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. Required.
  170. - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
  171. - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
  172. - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
  173. - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
  174. - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required.
  175. - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
  176. - `--user-dn value`: The user’s DN. Required.
  177. - Examples:
  178. - `gitea admin auth add-ldap-simple --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-dn "cn=%s,ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(cn=%s))" --email-attribute mail`
  179. - `update-ldap-simple`: Update existing LDAP (simple auth) authentication source
  180. - Options:
  181. - `--id value`: ID of authentication source. Required.
  182. - `--name value`: Authentication name.
  183. - `--not-active`: Deactivate the authentication source.
  184. - `--security-protocol value`: Security protocol name.
  185. - `--skip-tls-verify`: Disable TLS verification.
  186. - `--host value`: The address where the LDAP server can be reached.
  187. - `--port value`: The port to use when connecting to the LDAP server.
  188. - `--user-search-base value`: The LDAP base at which user accounts will be searched for.
  189. - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate.
  190. - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
  191. - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
  192. - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
  193. - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
  194. - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address.
  195. - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
  196. - `--user-dn value`: The user’s DN.
  197. - Examples:
  198. - `gitea admin auth update-ldap-simple --id 1 --name "my ldap auth source"`
  199. - `gitea admin auth update-ldap-simple --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn`
  200. #### cert
  201. Generates a self-signed SSL certificate. Outputs to `cert.pem` and `key.pem` in the current
  202. directory and will overwrite any existing files.
  203. - Options:
  204. - `--host value`: Comma seperated hostnames and ips which this certificate is valid for.
  205. Wildcards are supported. Required.
  206. - `--ecdsa-curve value`: ECDSA curve to use to generate a key. Optional. Valid options
  207. are P224, P256, P384, P521.
  208. - `--rsa-bits value`: Size of RSA key to generate. Optional. Ignored if --ecdsa-curve is
  209. set. (default: 2048).
  210. - `--start-date value`: Creation date. Optional. (format: `Jan 1 15:04:05 2011`).
  211. - `--duration value`: Duration which the certificate is valid for. Optional. (default: 8760h0m0s)
  212. - `--ca`: If provided, this cert generates it's own certificate authority. Optional.
  213. - Examples:
  214. - `gitea cert --host git.example.com,example.com,www.example.com --ca`
  215. #### dump
  216. Dumps all files and databases into a zip file. Outputs into a file like `gitea-dump-1482906742.zip`
  217. in the current directory.
  218. - Options:
  219. - `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip).
  220. - `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
  221. - `--skip-repository`, `-R`: Skip the repository dumping. Optional.
  222. - `--database`, `-d`: Specify the database SQL syntax. Optional.
  223. - `--verbose`, `-V`: If provided, shows additional details. Optional.
  224. - Examples:
  225. - `gitea dump`
  226. - `gitea dump --verbose`
  227. #### generate
  228. Generates random values and tokens for usage in configuration file. Useful for generating values
  229. for automatic deployments.
  230. - Commands:
  231. - `secret`:
  232. - Options:
  233. - `INTERNAL_TOKEN`: Token used for an internal API call authentication.
  234. - `JWT_SECRET`: LFS & OAUTH2 JWT authentication secret (LFS_JWT_SECRET is aliased to this option for backwards compatibility).
  235. - `SECRET_KEY`: Global secret key.
  236. - Examples:
  237. - `gitea generate secret INTERNAL_TOKEN`
  238. - `gitea generate secret JWT_SECRET`
  239. - `gitea generate secret SECRET_KEY`
  240. #### keys
  241. Provides an SSHD AuthorizedKeysCommand. Needs to be configured in the sshd config file:
  242. ```ini
  243. ...
  244. # The value of -e and the AuthorizedKeysCommandUser should match the
  245. # username running gitea
  246. AuthorizedKeysCommandUser git
  247. AuthorizedKeysCommand /path/to/gitea keys -e git -u %u -t %t -k %k
  248. ```
  249. The command will return the appropriate authorized_keys line for the
  250. provided key. You should also set the value
  251. `SSH_CREATE_AUTHORIZED_KEYS_FILE=false` in the `[server]` section of
  252. `app.ini`.
  253. NB: opensshd requires the gitea program to be owned by root and not
  254. writable by group or others. The program must be specified by an absolute
  255. path.
  256. #### migrate
  257. Migrates the database. This command can be used to run other commands before starting the server for the first time.
  258. This command is idempotent.
  259. #### convert
  260. Converts an existing MySQL database from utf8 to utf8mb4.