@@ -30,6 +30,7 @@ import yargs from "yargs";
30
30
export type SshCommandArgs = {
31
31
destination : string ;
32
32
command ?: string ;
33
+ requestGroup ?: boolean ;
33
34
L ?: string ; // Port forwarding option
34
35
N ?: boolean ; // No remote command
35
36
arguments : string [ ] ;
@@ -88,6 +89,11 @@ export const sshCommand = (yargs: yargs.Argv) =>
88
89
describe :
89
90
"Do not execute a remote command. Useful for forwarding ports." ,
90
91
} )
92
+ . option ( "request-group" , {
93
+ type : "boolean" ,
94
+ describe :
95
+ "Request access to all other instances that share a group with the destination" ,
96
+ } )
91
97
// Match `p0 request --reason`
92
98
. option ( "reason" , {
93
99
describe : "Reason access is needed" ,
@@ -163,6 +169,27 @@ const ssh = async (args: yargs.ArgumentsCamelCase<SshCommandArgs>) => {
163
169
// Prefix is required because the backend uses it to determine that this is an AWS request
164
170
const authn = await authenticate ( ) ;
165
171
await validateSshInstall ( authn ) ;
172
+
173
+ if ( args . requestGroup ) {
174
+ // When requesting for a group of a specific node first gain access to the group. Subsequent
175
+ // requests will detect that the node is a part of the group and can use the group permission
176
+ // to gain access to the node.
177
+ const response = await request (
178
+ {
179
+ ...pick ( args , "$0" , "_" ) ,
180
+ arguments : [ "ssh" , "group" , "--destination" , args . destination ] ,
181
+ wait : true ,
182
+ } ,
183
+ authn ,
184
+ { message : "approval-required" }
185
+ ) ;
186
+ if ( ! response ) {
187
+ print2 ( "Did not receive access ID from server" ) ;
188
+ return ;
189
+ }
190
+ await waitForProvisioning < AwsSsh > ( authn , response . id ) ;
191
+ }
192
+
166
193
const response = await request < AwsSsh > (
167
194
{
168
195
...pick ( args , "$0" , "_" ) ,
0 commit comments