0 vote
Hello
I have to create hundreds of SSH Tunnel for IoT devices.
I've a excel file with:
External IP
Internal IP
External Port
Internal Port
Username
Password
Local Port
In your csv import I cant' find local IP, Loca Port, Remote Port, Remote IP
Is it possibile to implement ?
It very useful when you'll have to create many tunnels. In IoT environment is important.
My best regards
Hello,
With a PowerShell script, it would be possible to import the entries from the CSV file.
Here is a quick sample script you must adapt to with settings to import the entries.
For more information about the Devolutions.PowerShell module, please see this article.
https://docs.devolutions.net/kb/devolutions-powershell/remote-desktop-manager/rdm-powershell-core-module/
To find any RDM object property, the following trick is the easiest and most accurate method we can use.
https://docs.devolutions.net/rdm/windows/powershell-scripting/tips-tricks/#reverse-engineering-an-entrys-structure
# Check if RDM PS module is installed
if(-not (Get-Module Devolutions.PowerShell -ListAvailable)){
Install-Module Devolutions.PowerShell -Scope CurrentUser
}
# 1 - Data source name you use in RDM
Set-RDMCurrentDataSource (Get-RDMDataSource -Name "Your Data Source name")
# 2 - Set the CSV file path and name
$filename = "path to your CSV file"
$CSVSSHTunnel = Import-Csv $fileName
foreach ($SSHTunnel in $CSVSSHTunnel)
{
$Session = New-RDMSession -Name $SSHTunnel.ExternalIP -Type SSHTunnel -SetSession
$Session.Terminal.Host = $SSHTunnel.ExternalIP
$Session.Terminal.HostPort = $SSHTunnel.ExternalPort
$PortForwardArray = @()
$itemPortForward = New-Object Devolutions.RemoteDesktopManager.Business.PortForward
$itemPortForward.Source = $SSHTunnel.InternalIP
$itemPortForward.SourcePort = $SSHTunnel.InternalPort
$PortForwardArray += $itemPortForward
$Session.Terminal.PortForwards = $PortForwardArray
Set-RDMSession $Session -Refresh
Set-RDMSessionUsername -Session $Session -UserName $SSHTunnel.UserName
$SSHPassword = ConvertTo-SecureString $SSHTunnel.Password -AsPlainText -Force
Set-RDMSessionPassword -Session $Session -Password $SSHPassword
Set-RDMSession $Session -Refresh
}
Write-Host "Import completed!!!"
Let us know if that helps or if you have further questions.
Best regards,
Érica Poirier