In the same terminal I need to switch user and be able to use gnugpg properly The next script (which could also be a bash alias) to switch the terminal shell to another user.
I want running this script to ask me only the password for the sudo command
login to the new user must skip the password request:
#!/bin/sh
sudo login nextuser
For some reason in my case it's not enough to use: su - nextuser
because I can't use gpg properly (probably because of gpg-agent initialization, show errors when using the signature), with the login
command gpg-agent works fine once logged in in the new session.