Fabric password

Each time the tag is executed, it asks for the root password, whether it can be sent at the same time for automatic offers.

fab staging test 
+35
python fabric
Feb 26 '10 at 5:48
source share
6 answers

fab -h will show you all the options, you can also read them here .

In particular, and I quote

-p PASSWORD, --password = PASSWORD

Sets env.password for a given string; it will be used as the default password when connecting SSH or calling the sudo program.

+47
Feb 26 2018-10-02T00
source share

I know what you asked about the password, but isn’t it better to set up this system so that you can do fabric (i.e. SSH) without a password?

To do this, on the local computer, run:

  • ssh-keygen and accept all defaults (unless you have a reason to do it differently)
  • cat ~/.ssh/id_rsa.pub and copy this key

On a remote computer:

  • mkdir ~/.ssh && chmod 700 ~/.ssh
  • touch ~/.ssh/authorized_keys2 && chmod 600 ~/.ssh/authorized_keys2
  • Paste the copied key into authorized_keys2

Now your remote computer "trusts" your local computer and allows you to register it without a password. Handy

+56
Feb 26 '10 at 10:29
source share

You can also set passwords for each node. This was not obvious to me, so here everything goes to someone who is looking for:

 from fabric import env env.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. He sets this cache using the full host string as the key of this dictionary and password as the value. If you install this dictionary yourself before performing any task, Fabric will not query them at all.

+50
Apr 6 2018-11-11T00:
source share

Just to add for everyone who comes here from the search, you can specify the -I option when running fab so that it suggests you use the default password. Thus, it will not be visible in the history of teams

Example:

 $ fab -I my_task Initial value for env.password: 
+8
Oct. 16 '13 at 16:01
source share

One way to do this without putting the password in the list of processes (commands displayed in ps aux) is to put it in the fabfile.py file, for example:

 from fabric.context_managers import env env.password = 'PASSWORD' 

Put this before going to the remote system and will no longer ask for a password.

+6
Mar 15 '11 at 21:23
source share

You can also set the ssh password in connect_args

  conn = Connection( "{username}@{ip}:{port}".format( username=username, ip=ip, port=port, ), connect_kwargs={"password": password}, ) 
0
Dec 04 '18 at 16:53
source share



All Articles