fabric password
I know you've asked about password but wouldn't it better to configure the system so that you can doing fabric (i.e. SSH) without password?
For this, on local machine do:
ssh-keygen
and agree with all defaults (if you have no reasons do otherwise)cat ~/.ssh/id_rsa.pub
and copy that key
On remote machine:
mkdir ~/.ssh && chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys2 && chmod 600 ~/.ssh/authorized_keys2
- Paste copied key into
authorized_keys2
From now your remote machine “trusts” your local machine and allows logging it in without password. Handy.
You can also set passwords on a per host basis.It wasn't obvious to me, so here it goes for anyone looking for this:
from fabric import envenv.hosts = ['user1@host1:port1', 'user2@host2.port2']env.passwords = {'user1@host1:port1': 'password1', 'user2@host2.port2': 'password2'}
Fabric caches used passwords in the env.passwords dictionary.It sets this cache using the full hosts string as key of that dictionary and the password as the value.If you set this dictionary yourself before executing any task, Fabric won't ask for them at all.