1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-12-07 23:03:08 +02:00
Files
OpenIntegrations/docs/en/md/SFTP/Common-methods/Create-connection.mdx

89 lines
2.5 KiB
Plaintext
Raw Normal View History

2025-09-26 09:27:29 +03:00
---
sidebar_position: 1
description: Create Connection and other functions to work with SFTP in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, SFTP]
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Create Connection
Creates a new SFTP session
`Function CreateConnection(Val SSHSettings, Val Proxy = "") Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| SSHSettings | - | Structure Of KeyAndValue | ✔ | Connection settings structure |
| Proxy | - | Structure Of KeyAndValue | ✖ | Proxy settings structure, if necessary |
Returns: Arbitrary, Map of KeyAndValue - Create Connection
<br/>
:::tip
Get the connection configuration using the functions `GetSettingsLoginPassword`, `GetSettingsPrivateKey`, `GetSettingsViaAgent`
:::
:::caution
**NOCLI:** this method is not available in CLI version
:::
<br/>
```bsl title="1C:Enterprise/OneScript code example"
2025-10-20 19:41:52 +03:00
Host = FunctionParameters["SSH_Host"];
Port = FunctionParameters["SSH_Port"];
2025-09-26 09:27:29 +03:00
UseProxy = True;
ProxySettings = Undefined;
AuthorizationType = "By login and password";
If AuthorizationType = "By login and password" Then
2025-10-20 19:41:52 +03:00
Login = FunctionParameters["SSH_User"];
Password = FunctionParameters["SSH_Password"];
2025-09-26 09:27:29 +03:00
2025-10-05 19:19:32 +03:00
SFTPSettings = OPI_SFTP.GetSettingsLoginPassword(Host, Port, Login, Password);
2025-09-26 09:27:29 +03:00
ElsIf AuthorizationType = "By key" Then
2025-10-20 19:41:52 +03:00
Login = FunctionParameters["SSH_User"];
2025-09-26 09:27:29 +03:00
PrivateKey = "./ssh_key";
PublicKey = "./ssh_key.pub";
2025-10-05 19:19:32 +03:00
SFTPSettings = OPI_SFTP.GetSettingsPrivateKey(Host, Port, Login, PrivateKey, PublicKey);
2025-09-26 09:27:29 +03:00
Else
2025-10-20 19:41:52 +03:00
Login = FunctionParameters["SSH_User"];
2025-10-05 19:19:32 +03:00
SFTPSettings = OPI_SFTP.GetSettingsViaAgent(Host, Port, Login);
2025-09-26 09:27:29 +03:00
EndIf;
If UseProxy Then
2025-10-20 19:41:52 +03:00
ProxyType = FunctionParameters["Proxy_Type"]; // http, socks5, socks4
2025-09-26 09:27:29 +03:00
2025-10-20 19:41:52 +03:00
ProxyAddress = FunctionParameters["Proxy_IP"];
ProxyPort = FunctionParameters["Proxy_Port"];
ProxyLogin = FunctionParameters["Proxy_User"];
ProxyPassword = FunctionParameters["Proxy_Password"];
2025-09-26 09:27:29 +03:00
ProxySettings = OPI_SFTP.GetProxySettings(ProxyAddress, ProxyPort, ProxyType, ProxyLogin, ProxyPassword);
EndIf;
2025-10-05 19:19:32 +03:00
Result = OPI_SFTP.CreateConnection(SFTPSettings, ProxySettings);
2025-09-26 09:27:29 +03:00
```
2025-10-07 19:27:04 +03:00
```json title="Result"
"AddIn.OPI_SSH.Main"
```