Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

command-line.en-us.md 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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 1024, 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. - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
  124. - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
  125. - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
  126. - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
  127. - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required.
  128. - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
  129. - `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user.
  130. - `--bind-password value`: The password for the Bind DN, if any.
  131. - `--attributes-in-bind`: Fetch attributes in bind DN context.
  132. - `--synchronize-users`: Enable user synchronization.
  133. - `--page-size value`: Search page size.
  134. - Examples:
  135. - `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`
  136. - `update-ldap`: Update existing LDAP (via Bind DN) authentication source
  137. - Options:
  138. - `--id value`: ID of authentication source. Required.
  139. - `--name value`: Authentication name.
  140. - `--not-active`: Deactivate the authentication source.
  141. - `--security-protocol value`: Security protocol name.
  142. - `--skip-tls-verify`: Disable TLS verification.
  143. - `--host value`: The address where the LDAP server can be reached.
  144. - `--port value`: The port to use when connecting to the LDAP server.
  145. - `--user-search-base value`: The LDAP base at which user accounts will be searched for.
  146. - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate.
  147. - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
  148. - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
  149. - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
  150. - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
  151. - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
  152. - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address.
  153. - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
  154. - `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user.
  155. - `--bind-password value`: The password for the Bind DN, if any.
  156. - `--attributes-in-bind`: Fetch attributes in bind DN context.
  157. - `--synchronize-users`: Enable user synchronization.
  158. - `--page-size value`: Search page size.
  159. - Examples:
  160. - `gitea admin auth update-ldap --id 1 --name "my ldap auth source"`
  161. - `gitea admin auth update-ldap --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn`
  162. - `add-ldap-simple`: Add new LDAP (simple auth) authentication source
  163. - Options:
  164. - `--name value`: Authentication name. Required.
  165. - `--not-active`: Deactivate the authentication source.
  166. - `--security-protocol value`: Security protocol name. Required.
  167. - `--skip-tls-verify`: Disable TLS verification.
  168. - `--host value`: The address where the LDAP server can be reached. Required.
  169. - `--port value`: The port to use when connecting to the LDAP server. Required.
  170. - `--user-search-base value`: The LDAP base at which user accounts will be searched for.
  171. - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. Required.
  172. - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
  173. - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
  174. - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
  175. - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
  176. - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
  177. - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required.
  178. - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
  179. - `--user-dn value`: The user’s DN. Required.
  180. - Examples:
  181. - `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`
  182. - `update-ldap-simple`: Update existing LDAP (simple auth) authentication source
  183. - Options:
  184. - `--id value`: ID of authentication source. Required.
  185. - `--name value`: Authentication name.
  186. - `--not-active`: Deactivate the authentication source.
  187. - `--security-protocol value`: Security protocol name.
  188. - `--skip-tls-verify`: Disable TLS verification.
  189. - `--host value`: The address where the LDAP server can be reached.
  190. - `--port value`: The port to use when connecting to the LDAP server.
  191. - `--user-search-base value`: The LDAP base at which user accounts will be searched for.
  192. - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate.
  193. - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
  194. - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
  195. - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
  196. - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
  197. - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
  198. - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address.
  199. - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
  200. - `--user-dn value`: The user’s DN.
  201. - Examples:
  202. - `gitea admin auth update-ldap-simple --id 1 --name "my ldap auth source"`
  203. - `gitea admin auth update-ldap-simple --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn`
  204. #### cert
  205. Generates a self-signed SSL certificate. Outputs to `cert.pem` and `key.pem` in the current
  206. directory and will overwrite any existing files.
  207. - Options:
  208. - `--host value`: Comma seperated hostnames and ips which this certificate is valid for.
  209. Wildcards are supported. Required.
  210. - `--ecdsa-curve value`: ECDSA curve to use to generate a key. Optional. Valid options
  211. are P224, P256, P384, P521.
  212. - `--rsa-bits value`: Size of RSA key to generate. Optional. Ignored if --ecdsa-curve is
  213. set. (default: 2048).
  214. - `--start-date value`: Creation date. Optional. (format: `Jan 1 15:04:05 2011`).
  215. - `--duration value`: Duration which the certificate is valid for. Optional. (default: 8760h0m0s)
  216. - `--ca`: If provided, this cert generates it's own certificate authority. Optional.
  217. - Examples:
  218. - `gitea cert --host git.example.com,example.com,www.example.com --ca`
  219. #### dump
  220. Dumps all files and databases into a zip file. Outputs into a file like `gitea-dump-1482906742.zip`
  221. in the current directory.
  222. - Options:
  223. - `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip).
  224. - `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
  225. - `--skip-repository`, `-R`: Skip the repository dumping. Optional.
  226. - `--database`, `-d`: Specify the database SQL syntax. Optional.
  227. - `--verbose`, `-V`: If provided, shows additional details. Optional.
  228. - Examples:
  229. - `gitea dump`
  230. - `gitea dump --verbose`
  231. #### generate
  232. Generates random values and tokens for usage in configuration file. Useful for generating values
  233. for automatic deployments.
  234. - Commands:
  235. - `secret`:
  236. - Options:
  237. - `INTERNAL_TOKEN`: Token used for an internal API call authentication.
  238. - `JWT_SECRET`: LFS & OAUTH2 JWT authentication secret (LFS_JWT_SECRET is aliased to this option for backwards compatibility).
  239. - `SECRET_KEY`: Global secret key.
  240. - Examples:
  241. - `gitea generate secret INTERNAL_TOKEN`
  242. - `gitea generate secret JWT_SECRET`
  243. - `gitea generate secret SECRET_KEY`
  244. #### keys
  245. Provides an SSHD AuthorizedKeysCommand. Needs to be configured in the sshd config file:
  246. ```ini
  247. ...
  248. # The value of -e and the AuthorizedKeysCommandUser should match the
  249. # username running gitea
  250. AuthorizedKeysCommandUser git
  251. AuthorizedKeysCommand /path/to/gitea keys -e git -u %u -t %t -k %k
  252. ```
  253. The command will return the appropriate authorized_keys line for the
  254. provided key. You should also set the value
  255. `SSH_CREATE_AUTHORIZED_KEYS_FILE=false` in the `[server]` section of
  256. `app.ini`.
  257. NB: opensshd requires the gitea program to be owned by root and not
  258. writable by group or others. The program must be specified by an absolute
  259. path.
  260. NB: Gitea must be running for this command to succeed.
  261. #### migrate
  262. Migrates the database. This command can be used to run other commands before starting the server for the first time.
  263. This command is idempotent.
  264. #### convert
  265. Converts an existing MySQL database from utf8 to utf8mb4.
  266. #### doctor
  267. Diagnose the problems of current gitea instance according the given configuration.
  268. Currently there are a check list below:
  269. - Check if OpenSSH authorized_keys file id correct
  270. When your gitea instance support OpenSSH, your gitea instance binary path will be written to `authorized_keys`
  271. when there is any public key added or changed on your gitea instance.
  272. Sometimes if you moved or renamed your gitea binary when upgrade and you haven't run `Update the '.ssh/authorized_keys' file with Gitea SSH keys. (Not needed for the built-in SSH server.)` on your Admin Panel. Then all pull/push via SSH will not be work.
  273. This check will help you to check if it works well.
  274. For contributors, if you want to add more checks, you can wrie ad new function like `func(ctx *cli.Context) ([]string, error)` and
  275. append it to `doctor.go`.
  276. ```go
  277. var checklist = []check{
  278. {
  279. title: "Check if OpenSSH authorized_keys file id correct",
  280. f: runDoctorLocationMoved,
  281. },
  282. // more checks please append here
  283. }
  284. ```
  285. This function will receive a command line context and return a list of details about the problems or error.