WordPress asks for your FTP credentials when it can’t access the files directly. This happens when PHP running as the different user (mod_php or CGI) rather than the user that owns your WordPress files. In my case it was when I tried to use WP over nginx. Switching over to using suPHP or FastCGI would probably fix it.

If you don’t want to work around there you can fix it in 3 ways :

  • Provide the FTP details every time it asks for.
  • Define your FTP credentials directly in wp-config.php.
    
    define( 'FTP_USER', 'username' );
    define( 'FTP_PASS', 'password' );
    define( 'FTP_HOST', 'ftp.yourdomain.com:21' );
    
  • Change the directory ownership. Navigate to your wordpress root directory and change ownership to www-data
    
    sudo chown -R www-data:www-data