Skip to content

Commit 69fbf06

Browse files
authored
Merge pull request #93 from Splaxi/extend-sftp-with-key-support
Extend sftp with key support
2 parents 44d52d5 + c4eb4a0 commit 69fbf06

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

PsLogicAppExtractor/internal/arms/API.SftpWithSsh.Username.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"portNumber": "##PORTNUMBER##",
1313
"rootFolder": "##ROOTFOLDER##",
1414
"acceptAnySshHostKey": true,
15-
"sshHostKeyFingerprint": ""
15+
"sshHostKeyFingerprint": "",
16+
"sshPrivateKey": "##SSHPRIVATEKEY##"
1617
},
1718
"displayName": "##NAME##",
1819
"customParameterValues": {},

PsLogicAppExtractor/internal/tasks/All/All.task.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,8 @@ Task -Name "Set-Arm.Connections.ManagedApis.SftpWithSsh.Username.Advanced.AsArmO
23882388
$rootPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_Rootfolder" -Value "$($_.Name)"
23892389
$acceptPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_AcceptAnySshHostkey" -Value "$($_.Name)"
23902390
$fingerPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_SshHostKeyFingerprint" -Value "$($_.Name)"
2391-
2391+
$sshKeyPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_SshPrivateKey" -Value "$($_.Name)"
2392+
23922393
$idPreSuf = Format-Name -Type "Connection" -Value "$($_.Name)"
23932394
$displayPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_DisplayName" -Value "$($_.Name)"
23942395

@@ -2426,7 +2427,12 @@ Task -Name "Set-Arm.Connections.ManagedApis.SftpWithSsh.Username.Advanced.AsArmO
24262427
-Type "string" `
24272428
-Value "$fingerprint" `
24282429
-Description "The fingerprint that you expect during the initial communication with the Sftp server. ($($_.Name))"
2429-
2430+
2431+
$armObj = Add-ArmParameter -InputObject $armObj -Name "$sshKeyPreSuf" `
2432+
-Type "SecureString" `
2433+
-Value "" `
2434+
-Description "The SSH private key used to authenticate against the Sftp server. Leave empty when using password authentication. ($($_.Name))"
2435+
24302436
$armObj = Add-ArmParameter -InputObject $armObj -Name "$displayPreSuf" `
24312437
-Type "string" `
24322438
-Value $displayName `
@@ -2447,6 +2453,7 @@ Task -Name "Set-Arm.Connections.ManagedApis.SftpWithSsh.Username.Advanced.AsArmO
24472453
$apiObj.Properties.ParameterValues.rootFolder = "[parameters('$rootPreSuf')]"
24482454
$apiObj.Properties.ParameterValues.acceptAnySshHostKey = "[parameters('$acceptPreSuf')]"
24492455
$apiObj.Properties.ParameterValues.sshHostKeyFingerprint = "[parameters('$fingerPreSuf')]"
2456+
$apiObj.Properties.ParameterValues.sshPrivateKey = "[parameters('$sshKeyPreSuf')]"
24502457

24512458
# Update the api connection object type
24522459
$_.Value.id -match "/managedApis/(.*)"

PsLogicAppExtractor/internal/tasks/Set-Arm.Connections.ManagedApis.SftpWithSsh.Username.Advanced.AsArmObject.task.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ Task -Name "Set-Arm.Connections.ManagedApis.SftpWithSsh.Username.Advanced.AsArmO
6060
$rootPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_Rootfolder" -Value "$($_.Name)"
6161
$acceptPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_AcceptAnySshHostkey" -Value "$($_.Name)"
6262
$fingerPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_SshHostKeyFingerprint" -Value "$($_.Name)"
63-
63+
$sshKeyPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_SshPrivateKey" -Value "$($_.Name)"
64+
6465
$idPreSuf = Format-Name -Type "Connection" -Value "$($_.Name)"
6566
$displayPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_DisplayName" -Value "$($_.Name)"
6667

@@ -98,7 +99,12 @@ Task -Name "Set-Arm.Connections.ManagedApis.SftpWithSsh.Username.Advanced.AsArmO
9899
-Type "string" `
99100
-Value "$fingerprint" `
100101
-Description "The fingerprint that you expect during the initial communication with the Sftp server. ($($_.Name))"
101-
102+
103+
$armObj = Add-ArmParameter -InputObject $armObj -Name "$sshKeyPreSuf" `
104+
-Type "SecureString" `
105+
-Value "" `
106+
-Description "The SSH private key used to authenticate against the Sftp server. Leave empty when using password authentication. ($($_.Name))"
107+
102108
$armObj = Add-ArmParameter -InputObject $armObj -Name "$displayPreSuf" `
103109
-Type "string" `
104110
-Value $displayName `
@@ -119,6 +125,7 @@ Task -Name "Set-Arm.Connections.ManagedApis.SftpWithSsh.Username.Advanced.AsArmO
119125
$apiObj.Properties.ParameterValues.rootFolder = "[parameters('$rootPreSuf')]"
120126
$apiObj.Properties.ParameterValues.acceptAnySshHostKey = "[parameters('$acceptPreSuf')]"
121127
$apiObj.Properties.ParameterValues.sshHostKeyFingerprint = "[parameters('$fingerPreSuf')]"
128+
$apiObj.Properties.ParameterValues.sshPrivateKey = "[parameters('$sshKeyPreSuf')]"
122129

123130
# Update the api connection object type
124131
$_.Value.id -match "/managedApis/(.*)"

0 commit comments

Comments
 (0)