The fabric.network.connect(user, host, port) function uses the function fabric.auth.get_password() to retrieve the password, and that function always return the password related to the current env.host_string.
This approach works with only one one level of connections, but when you use a env.gateway setting, the first connect host parameter will match the env.host_string content, so it will retrieve the wrong password.
Example:
from fabric.api import *
@task(default=True)
@hosts('user@host')
@with_settings(
no_keys=True,
gateway='gwuser@gwhost',
passwords={
'user@host':'pass',
'gwuser@gwhost':'gwpass',
}
)
def run():
run('uname -n')
This will end to a try to log on 'gwuser@gwhost' using 'pass' as password instead of 'gwpass'.
The fabric.network.connect(user, host, port) function uses the function fabric.auth.get_password() to retrieve the password, and that function always return the password related to the current env.host_string.
This approach works with only one one level of connections, but when you use a env.gateway setting, the first connect host parameter will match the env.host_string content, so it will retrieve the wrong password.
Example:
This will end to a try to log on 'gwuser@gwhost' using 'pass' as password instead of 'gwpass'.