Sometimes an owner/group mismatch in just one of the directories or subdirectories of your install can be enough to make WP_Filesystem
see that the permissions don’t match and ask for your FTP details instead.
eg. I have had this when copying/installing a plugin as root
user via SSH, forgot about setting the owner/group, and then then plugin won’t update directly later without fixing them.
You could try to track down those permissions and change them individually, but a good overall and fast solution to try is to simply update the owner/group permissions of your entire install recursively (from the level below public_html
or your install root.) This has the added bonus of fixing any other permissions you may have forgot to fix too:
chown -R www-data:www-data public_html
Where www-data
is your “web” user (will not be the same for everyone. eg. admin, apache)
Note this is a slightly shortcut method that is also the same as setting owner and group separately:
chown -R www-data public_html
chgrp -R www-data public_html