How to disable the standard Magento 2 authentication timeouts from the command line?

We will do the following:

  1. «Advanced» → «Admin» → «Security» → «Password Lifetime (days)»
    Set it to an empty value.
  2. «General» → «Web» → «Default Cookie Settings» → «Cookie Lifetime»
    Set it to 1 year.
  3. «Advanced» → «Admin» → «Security» → «Admin Session Lifetime (seconds)»
    Set it to 1 year.

1. Magento >= 2.2

bin/magento config:set web/cookie/cookie_lifetime 31536000
bin/magento config:set admin/security/session_lifetime 31536000
bin/magento config:set admin/security/password_lifetime ''
bin/magento cache:clean

2. Magento < 2.2

mysql --host=<host> --user=<user> --password=<password> -D <database> -e "\
	UPDATE core_config_data \
	SET value = (case \
		when path = 'admin/security/password_lifetime' then '' \
		when path = 'admin/security/session_lifetime' then 31536000 \
		when path = 'web/cookie/cookie_lifetime' then 31536000 \
	end) \
	WHERE path in (  \
		'admin/security/password_lifetime' \
		,'admin/security/session_lifetime' \
		,'web/cookie/cookie_lifetime' \
	); \
";
bin/magento cache:clean