5454 ' username=s' => \(my $username ),
5555 ' password=s' => \(my $password ),
5656 ' timeout=n' => \(my $timeout ),
57+ ' sshkeyfile=s' => \(my $sshkeyfile ),
5758 ' force' => \(my $force ),
5859 ' all' => (\my $all ),
5960 ' version' => \(my $print_version ),
9091 exit (1);
9192 }
9293
93- } elsif ((lc $action eq ' lock' ) || (lc $action eq ' unlock' ) || (lc $action eq ' password' ) || (lc $action eq ' timeout' )) {
94+ } elsif ((lc $action eq ' lock' ) || (lc $action eq ' unlock' ) || (lc $action eq ' password' ) || (lc $action eq ' timeout' )
95+ || (lc $action eq ' sshkey' ) ) {
9496
9597 if (!defined ($username )) {
9698 print " Parameter -username is required for action $action \n " ;
104106 exit (1);
105107 }
106108
109+ if ((lc $action eq ' sshkey' ) && !defined ($sshkeyfile )) {
110+ print " Parameter -sshkeyfile is required for action $action \n " ;
111+ pod2usage(-verbose => 1, -input => \*DATA );
112+ exit (1);
113+ }
114+
107115} else {
108116 print " Unknown action $action \n " ;
109117 pod2usage(-verbose => 1, -input => \*DATA );
134142 }
135143
136144 if (defined ($file ) || defined ($username )) {
137- $ret = $ret + process_user($engine_obj , $file , $action , $username , $jscontainers , $timeout );
145+ if (lc $action eq ' sshkey' ) {
146+ my $users_obj = new Users ($engine_obj , undef , $debug );
147+ my $loginuser = $users_obj -> getCurrentUser();
148+ $ret = $ret + $users_obj -> setSSHkey($username , $loginuser -> {userType }, $sshkeyfile );
149+ } else {
150+ $ret = $ret + process_user($engine_obj , $file , $action , $username , $jscontainers , $timeout );
151+ }
138152 }
139153
140154 if (defined ($profile )) {
@@ -350,10 +364,11 @@ =head1 SYNOPSIS
350364
351365 dx_ctl_users [ -engine|d <delphix identifier> | -all ] [ -configfile file ]
352366 [-action import] <-file filename | -profile filename >
353- -action lock|unlock|password|timeout
367+ -action lock|unlock|password|timeout|sshkey
354368 -username name|all
355369 [-password password]
356370 [-timeout timeout]
371+ [-sshkeyfile filename]
357372 [-help|?]
358373 [-debug]
359374
@@ -386,7 +401,7 @@ =head2 Options
386401
387402=over 4
388403
389- =item B<-action import|lock|unlock|password >
404+ =item B<-action import|lock|unlock|password|sshkey >
390405Action for a particular user or file
391406Actions:
392407
@@ -395,6 +410,7 @@ =head2 Options
395410 - unlock - enable (unlock) user account
396411 - password - change user password
397412 - timeout - change user timeout
413+ - sshkey - set a user SSH key
398414
399415=item B<-username user|all >
400416Username for particular action.
@@ -406,6 +422,9 @@ =head2 Options
406422=item B<-timeout time >
407423Update a timeout for an user. Timeout is set in minutes
408424
425+ =item B<-sshkeyfile filename >
426+ File with one or more SSH public key to set for user
427+
409428=item B<-file filename >
410429CSV file name with user definition and actions. Field list as follow:
411430
@@ -549,4 +568,9 @@ =head1 EXAMPLES
549568 User js deleted.
550569 User js created.
551570
571+ Setting a SSH key for user
572+
573+ dx_ctl_users -d 53 -action sshkey -username admin -sshkeyfile /tmp/id_rsa.pub
574+ SSH key for admin set.
575+
552576=cut
0 commit comments