Reputation: 124
I am using python fabric and want to login as user.
this is my initial command prompt: root@vm
I have created a user named "hduser" with the password "cisco" Now i would like to login to hduser and execute commands as hduser.
when I execute the command
run("su - hduser")
It will prompt me for an password. Is it possible to set the password initially for "hduser" and it just execute the command as hduser instead of root.?
This is the output .
fab -f fabfile.py list1 script
[pc8.utahddc.geniracks.net:32314] Executing task 'script'
[pc8.utahddc.geniracks.net:32314] run: su - hduser
[pc8.utahddc.geniracks.net:32314] out: Password:
It is asking password. How can i pass the password for this ?
Upvotes: 0
Views: 1847
Reputation: 2939
I am not sure if I did understand what your question is.
However if you want to avoid entering the password you could store it in env.password
or use the command line arguments --password
or --initial-password-prompt
.
For more details see Fabric Dokumentation for Password management.
Upvotes: 1