I am writing a command line app in Go that allows automating the configuration of networking devices over SSH. Unfortunately, most of these devices are configured for password authentication rather than key authentication. Is there a way to temporarily and securely store the user's password for only the current terminal session? Similar to how setting an environment variable with export ENV_VAR=<value>
only stores the environment variable for the current session. For example, a user opens the terminal, runs my CLI, and is prompted for their password. For subsequent calls to my program, I'd like to not prompt the user for their password again. If the user closes their terminal then comes back later, however, I would want the password prompt to reappear when my CLI is called. If possible, I would like to do this without using a database since the number of users of my CLI will be very small.