sftp_connect: Create a list object with SFTP connection details

Description Usage Arguments Value See Also Examples

View source: R/sftp_functions.R

Description

sftp_connect outputs a list which is used as an argument to all other functions of the sftp package. Recommended practice is to store the output as sftp_con since that is the object name all other sftp functions look for by default. IMPORTANT! Your password MUST NOT contain the colon character : or the at-sign @ since these characters have special use as delimiters in the connection string! Questions? https://github.com/stenevang/sftp

Usage

1
2
3
4
5
6
7
8
9
sftp_connect(
  server = "localhost",
  folder = NULL,
  username = NULL,
  password = NULL,
  protocol = "sftp://",
  port = 22,
  timeout = 30
)

Arguments

server

This is the SFTP server URL or hostname or IP-adress. Default is localhost.

folder

This is the path to the folder where you want to operate. The value can be a single folder name in the SFTP root or a path with subfolders, like 'dir1/dir2/dir3'. Note that directory names are CaSe SeNsItIvE. Default is NULL, which takes you to the root folder.

username

The SFTP account username. It is recommended to not store your username in any script, but instead create a System Environment Variable and call it using Sys.getenv Default is NULL.

password

The SFTP account password. It is recommended to not store your password in any script, but instead create a System Environment Variable and call it using Sys.getenv IMPORTANT! Your password MUST NOT contain the colon character : or the at-sign @ since these characters have special use as delimiters in the connection string! Default is NULL.

protocol

Default is 'sftp://'. You will probably never change this value.

port

Default is '22'. You will probably never change this value. Theoretically, an SFTP server could be set up to respond on a port other than the default port 22.

timeout

RCurl connection timeout in seconds. Default is 30.

Value

The function returns a list of strings which are used by all other functions in the sftp package when connecting to an SFTP server.

See Also

See listing here: sftp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# minimal - rely on defaults
sftp_con <- sftp_connect(username = Sys.getenv("MY_SFTP_USER"),
                         password = Sys.getenv("MY_SFTP_PASS"))

# explicit
sftp_con <- sftp_connect(server = "mysftp.com",
                         folder = "myfolder",
                         username = Sys.getenv("MY_SFTP_USER"),
                         password = Sys.getenv("MY_SFTP_PASS"),
                         protocol = "sftp://",
                         port = 22,
                         timeout = 60)

stenevang/sftp documentation built on Feb. 8, 2022, 6:40 p.m.