Google me dice esto. Puede que tengas que Implementar un plug-in. To implement OTP (One-Time Password) for Google Cloud SQL PostgreSQL instances, you can use built-in authentication with username and password or IAM database authentication, and potentially integrate a 2FA solution like pg_otp or pg_ident with OTP
https://www.google.com/search?q=OTP+google+postgresql+&client=firefox-b-d&sca_esv=6032389a2ad49ca8&sxsrf=AHTn8zpi2do6uhPGEHYmiq_-lc009Cs3CA%3A1741305265580&ei=sTXKZ5-GI-Gs4-EP2-3JuQM&ved=0ahUKEwjforPO0_aLAxVh1jgGHdt2MjcQ4dUDCBA&uact=5&oq=OTP+google+postgresql+&gs_lp=Egxnd3Mtd2l6LXNlcnAiFk9UUCBnb29nbGUgcG9zdGdyZXNxbCAyBRAhGKABMgUQIRifBUiQEFD7BFiHD3ABeAGQAQCYAdQDoAGgFaoBBTMtMy40uAEDyAEA-AEBmAIIoAK-FcICChAAGLADGNYEGEfCAg0QABiABBiwAxhDGIoFwgIFEAAYgATCAgsQABiABBiRAhiKBcICBhAAGBYYHsICCBAAGBYYChgewgIHECEYoAEYCpgDAIgGAZAGCZIHBzEuMy0zLjSgB8QV&sclient=gws-wiz-serp > On 7 Mar 2025, at 11:01 AM, Alejandro Carrillo <faster...@yahoo.es> wrote: > > Cordial saludo compañeros. > > Por favor alguien sabe si ha logrado usar Google Authenticator para generar > OTP (One Time Password), y que esa clave de un solo uso se pueda utilizar en > PgAdmin? > He logrado conectarme con ella usando PAM en psql, activando en el > pg_hba.conf así: > > # Permitir conexiones remotas usando PAM (OTP) > host all all 0.0.0.0/0 pam > host all all ::/0 pam > > Así me conecto exitosamente: > > psql -h 192.168.1.100 -p 5432 -U postgres -d postgres > > > Cuando me conecto desde PgAdmin, me pide el código de Google Authenticator y > me deja conectar exitosamente. Pero cuando abro una ventana de SQL, me genera > error de PAM: > > connection failed: connection to server at "11.0.0.13", port 5432 failed: > FATAL: la autentificación PAM falló para el usuario «postgres» > connection to server at "11.0.0.13", port 5432 failed: FATAL: la > autentificación PAM falló para el usuario «postgres» > > Si miro los logs de /var/log/auth.log me encuentro con que reintenta utilizar > el mismo código para volverse a loguear, lo cual demuestra que está tratando > de reconectarse: > > Mar 6 16:54:46 MiPC postgresql(pam_google_authenticator)[5743]: Accepted > google_authenticator for postgres > Mar 6 16:54:53 MiPC postgresql(pam_google_authenticator)[5769]: Trying to > reuse a previously used time-based code. > ("/var/lib/postgresql/.google_authenticator")Retry again in 30 seconds. > Warning! This might mean, you are currently subject to a man-in-the-middle > attack. > Mar 6 16:54:53 MiPC postgresql(pam_google_authenticator)[5769]: Invalid > verification code for postgres > Mar 6 16:54:53 MiPC postgresql(pam_google_authenticator)[5770]: Trying to > reuse a previously used time-based code. > ("/var/lib/postgresql/.google_authenticator")Retry again in 30 seconds. > Warning! This might mean, you are currently subject to a man-in-the-middle > attack. > Mar 6 16:54:53 MiPC postgresql(pam_google_authenticator)[5770]: Invalid > verification code for postgres > > Por consiguiente, me gustaría que solo se conectara una vez desde pgAdmin y > reutilizase la conexión para todo lo que necesita. > > Intenté con pgBouncer pero no funcionó. > > Agradezco su colaboración con este tema.