sftp
Upload or download files using SSH. This command is also executed by the SSHExecutor and therefor all ssh-related settings can be used. SSH-sessions can also be used with the sftp-command!
Note
This command caches all the settings so that they only need to be defined once.
vars:
$SERVER_ADDRESS: 192.42.0.254
$SSH_SERVER: 10.10.10.19
commands:
- type: sftp
cmd: put
local_path: /tmp/linpeas.sh
remote_path: /tmp/linpeas.sh
hostname: $SSH_SERVER
username: aecid
key_filename: "/home/alice/.ssh/id_rsa"
creates_session: "attacker"
# cached ssh-settings. creates new ssh-connection
- type: sftp
cmd: get
remote_path: /etc/passwd
local_path: /tmp/remote_passwd
# reuses existing session "attacker"
- type: ssh
session: "attacker"
cmd: "id"
- cmd
SFTP-command to use. Valid commands are put or get.
- Type:
str
- Required:
True
- remote_path
The filepath on the remote machine.
- Type:
str
- Required:
True
- local_path
The filepath on the local machine.
- Type:
str
- Required:
True
- mode
The file permissions on the remote file(e.g. 755).
- Type:
str
- hostname
This option sets the hostname or ip-address of the remote ssh-server.
- Type:
str
- port
Port to connect to on the remote host.
- Type:
int
- Default:
22
- username
Specifies the user to log in as on the remote machine.
- Type:
str
- password
Specifies the password to use. An alternative would be to use a key_file.
- Type:
str
- passphrase
Use this passphrase to decrypt the key_file. This is only necessary if the keyfile is protected by a passphrase.
- Type:
str
- key_filename
Path to the keyfile.
- Type:
str
- timeout
The timeout to drop a connection attempt in seconds.
- Type:
float
- clear_cache
Normally all settings for ssh-connections are cached. This allows to defined all settings in one command and all following commands can reuse these settings without set them in every single command. If a new connection with different settings should be configured, this setting allows to reset the cache to default values.
- Type:
bool
- Default:
False
Note
This setting will not clear the session store.
- creates_session
A session name that identifies the session that is created when executing this command. This session-name can be used by using the option “session”
- Type:
str
- session
Reuse an existing ssh-session. This setting works only if another ssh-command was executed with the command-option “creates_session”
- Type:
str
- jmp_hostname
This option sets the hostname or ip-address of the remote jump server.
- Type:
str
- jmp_port
Port to connect to on the jump-host.
- Type:
int
- Default:
22
- jmp_username
Specifies the user to log in as on the jmp-host.
- Type:
str
- Default:
same as username