Friday, January 16, 2015

Scripting user passwords in Proxmox 3.3

Proxmox has had a bug in their pveum code for some time now in that it won't let you directly script the user passwords when adding a user, or when changing a user's password. The usage info SAYS you can give passwords on the command line, but it doesn't work.

Well, I figured out a workaround. After realizing that pveum is a perl script, I found this post at this post at perlmonks.org which led me to make a small change to the line which reads the password to allow for redirected text to be accepted.

The change is in a subroutine beginning with "my $read_password = sub {" (line 49 on my system) to accept redirection. The blue is from the original file, the red reflects my change.

# diff pveum.original pveum.fixed
49c49
<     my $term = new Term::ReadLine ('pveum');
---
>     my $term = new Term::ReadLine ('pveum', \*STDIN, \*STDOUT);

So now I can update a password by redirecting the password string from Bash.

# printf "mypassword\nmypassword\n" | pveum passwd myuser@pve

No comments:

Post a Comment