hide passwords in drupal module settings
As you've already noted in the question, you can set '#access' =&gt; FALSE to any form element to remove it from display.

The correct place for this is in hook_form_alter():

function MYMODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'relevant_form_id') {
    $form['some_element']['#access'] = FALSE;
  }
}


If you're asking for a way to do this generically, without having to target each element with a specific form ID/element key, then you're out of luck. Those fields are nothing special, just standard text fields, so there's nothing to distinguish them from any other text field.

Bottom line - you need to decide exactly what fields you want to disable, find the appropriate form IDs/element keys, and use the method above to apply the rule one-by-one.