Skip to content

Commit

Permalink
Merge pull request #197 from jolicode/ssh-doc
Browse files Browse the repository at this point in the history
Update SSH documentation
  • Loading branch information
lyrixx authored Nov 14, 2023
2 parents 19e6998 + 6aa4675 commit ac4d4e4
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions doc/11-ssh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SSH and remote servers

Castor supports running commands on remote servers through SSH with the `ssh()`
## Run SSH commands

Castor supports running commands on remote servers through SSH with the `ssh_run()`
function:

```php
Expand All @@ -12,7 +14,7 @@ use function Castor\ssh;
function ls(): void
{
// List content of /var/www directory on the remote server
ssh('ls -alh', host: 'server-1.example.com', user: 'debian', sshOptions: [
ssh_run('ls -alh', host: 'server-1.example.com', user: 'debian', sshOptions: [
'port' => 2222,
], path: '/var/www');
}
Expand All @@ -21,10 +23,32 @@ function ls(): void
> **Note**
> This feature is marked as experimental and may change in the future.
## Available options
## Upload and download files

Castor provides 2 functions `ssh_upload()` and `ssh_download()` to exchange files
between localhost and a remote server:

```php
#[AsTask]
function upload_file(): void
{
ssh_upload('/tmp/test.html', '/var/www/index.html', host: 'server-1.example.com', user: 'debian');
}

#[AsTask]
function download_file(): void
{
ssh_download('/tmp/test.html', '/var/www/index.html', host: 'server-1.example.com', user: 'debian');
}
```

> **Note**
> These functions are marked as experimental and may change in the future.
## Available SSH options

You can pass additional options in the `ssh_options` argument of the `ssh()`
function. The following options are currently available:
All `ssh_xxx()` functions offer an additional `ssh_options` argument to configure
the SSH connection. The following options are currently available:

- `port`: port to use to connect to the remote server (default: 22)
- `path_private_key`: path to the private key to use to connect to the remote
Expand Down

0 comments on commit ac4d4e4

Please sign in to comment.