blob: 123a167f719602e1147073c26d4a6ececd2d9f13 [file] [view]
## Capabilities
This service can be used to:
- [x] create_dir
- [x] stat
- [x] read
- [x] write
- [x] delete
- [x] list
- [x] copy
- [x] rename
- [ ] ~~presign~~
## Configuration
- `endpoint`: Set the endpoint for connection. The format is same as `openssh`, using either `[user@]hostname` or `ssh://[user@]hostname[:port]`. A username or port that is specified in the endpoint overrides the one set in the builder (but does not change the builder).
- `root`: Set the work directory for backend. It uses the default directory set by the remote `sftp-server` as default
- `user`: Set the login user
- `key`: Set the public key for login
- `known_hosts_strategy`: Set the strategy for known hosts, default to `Strict`
- `enable_copy`: Set whether the remote server has copy-file extension
For security reasons, it doesn't support password login, you can use public key or ssh-copy-id instead.
You can refer to [`SftpBuilder`]'s docs for more information
## Example
### Via Builder
```rust,no_run
use anyhow::Result;
use opendal_service_sftp::Sftp;
use opendal_core::Operator;
#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Sftp::default()
.endpoint("127.0.0.1")
.user("test")
.key("test_key");
let op: Operator = Operator::new(builder)?.finish();
Ok(())
}
```