Skip to content

Commit 6fa1986

Browse files
committed
Initial.
0 parents  commit 6fa1986

16 files changed

+2415
-0
lines changed

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2018 Moriyoshi Koizumi
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
20+

README.md

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# s3-sftp-proxy
2+
3+
`s3-ftp-proxy` is a tiny program that exposes the resources on your AWS S3 buckets through SFTP protocol.
4+
5+
## Usage
6+
7+
```
8+
Usage of s3-sftp-proxy:
9+
-bind string
10+
listen on addr:port
11+
-config string
12+
configuration file (default "s3-sftp-proxy.toml")
13+
-debug
14+
turn on debugging output
15+
```
16+
17+
* `-bind`
18+
19+
Specifies the local address and port to listen on. This overrides the value of `bind` in the configuration file. If it is not present in the configuration file either, it defauls to `:10022`.
20+
21+
* `-config`
22+
23+
Specifies the path to the configuration file. It defaults to "./s3-sftp-config.toml" if not given.
24+
25+
* `-debug`
26+
27+
Turn on debug logging. The output will be more verbose.
28+
29+
30+
## Configuation
31+
32+
### Top level
33+
34+
```toml
35+
host_key_file = "./host_key"
36+
bind = "localhost:10022"
37+
banner = """
38+
Welcome to my SFTP server
39+
"""
40+
reader_lookback_buffer_size = 1048576
41+
reader_min_chunk_size = 262144
42+
lister_lookback_buffer_size = 100
43+
44+
# buckets and authantication settings follow...
45+
```
46+
47+
* `host_key_file` (required)
48+
49+
Specifies the path to the host key file (private key).
50+
51+
The host key can be generated with `ssh-keygen` command:
52+
53+
```sh
54+
ssh-keygen -f host_key
55+
```
56+
57+
* `bind` (optional, defaults to `":10022"`)
58+
59+
Specifies the local address and port to listen on.
60+
61+
* `banner` (optional, defaults to an empty string)
62+
63+
A banner is a message text that will be sent to the client when the connection is esablished to the server prior to any authentication steps.
64+
65+
* `reader_lookback_buffer_size` (optional, defaults to `1048576`)
66+
67+
Specifies the size of the buffer used to keep several amount of the data read from S3 for later access to it. The reason why such buffer is necessary is that SFTP protocol requires the data should be sent or retrieved on a random-access basis (i.e. each request contains an offset) while those coming from S3 is actually fetched in a streaming manner. In that we have to emulate block storage access for S3 objects, but chances are we don't need to hold the entire data with the reasonable SFTP clients.
68+
69+
* `reader_min_chunk_size` (optional, defaults to `262144`)
70+
71+
Specifies the amount of data fetched from S3 at once. Increase the value when you experience quite a poor performance.
72+
73+
* `lister_lookback_buffer_size` (optional, defalts to `100`)
74+
75+
Contrary to the people's expectation, SFTP also requires file listings to be retrieved in random-access as well.
76+
77+
* `buckets` (required)
78+
79+
`buckets` contains records for bucket declarations. See [Bucket Settings](#bucket_configuration) for detail.
80+
81+
* `auth`
82+
83+
`auth` contains records for authenticator configurations. See [Authenticator Settings](#authenticator_settings) for detail.
84+
85+
### Bucket Settings
86+
87+
```toml
88+
[buckets.test]
89+
bucket = "BUCKET"
90+
key_prefix = "PREFIX"
91+
bucket_url = "s3://BUCKET/PREFIX"
92+
profile = "profile"
93+
region = "ap-northeast-1"
94+
max_object_size = 65536
95+
writable = false
96+
readable = true
97+
listable = true
98+
auth = "test"
99+
server_side_encryption = "kms"
100+
sse_customer_algorithm = ""
101+
sse_customer_key = ""
102+
sse_kms_key_id = ""
103+
104+
[buckets.test.credentials]
105+
aws_access_key_id = "aaa"
106+
aws_secret_access_key = "bbb"
107+
```
108+
109+
* `bucket` (required when `bucket_url` is unspecified)
110+
111+
Specifies the bucket name.
112+
113+
* `key_prefix` (required when `bucket_url` is unspecified)
114+
115+
Specifies the prefix prepended to the file path sent from the client. The key string is derived as follows:
116+
117+
`key` = `key_prefix` + `path`
118+
119+
* `bucket_url` (required when `bucket` is unspecified)
120+
121+
Specifies both the bucket name and prefix in the URL form. The URL's scheme must be `s3`, and the host part corresponds to `bucket` while the path part does to `key_prefix`. You may not specify `bucket_url` and either `bucket` or `key_prefix` at the same time.
122+
123+
* `profile` (optional, defaults to the value of `AWS_PROFILE` unless `credentials` is specified)
124+
125+
Specifies the credentials profile name.
126+
127+
* `region` (optional, defaults to the value of `AWS_REGION` environment variable)
128+
129+
Specifies the region of the endpoint.
130+
131+
* `credentials` (optional)
132+
133+
* `credentials.aws_access_key_id` (required)
134+
135+
Specifies the AWS access key.
136+
137+
* `credentials.aws_secret_access_key` (required)
138+
139+
Specifies the AWS secret access key.
140+
141+
* `max_object_size` (optional, defaults to unlimited)
142+
143+
Specifies the maximum size of an object put to S3. This actually sets the size of the in-memory buffer used to hold the entire content sent from the client, as we have to calculate a MD5 sum for it before uploading there.
144+
145+
* `readable` (optional, defaults to `true`)
146+
147+
Specifies whether to allow the client to fetch objects from S3.
148+
149+
* `writable` (optional, defaults to `true`)
150+
151+
Specifies whether to allow the client to put objects to S3.
152+
153+
* `listable` (optional, defaults to `true`)
154+
155+
Specifies whether to allow the client to list objects in S3.
156+
157+
* `server_side_encryption` (optional, defaults to `"none"`)
158+
159+
Specifies which server-side encryption scheme is applied to store the objects. Valid values are: `"aes256"` and `"kms"`.
160+
161+
* `sse_customer_key` (required when `server_side_encryption` is set to `"aes256"`)
162+
163+
Specifies the base64-encoded encryption key. As the cipher is AES256-CBC, the key must be 256-bits long (32 bytes)
164+
165+
* `sse_kms_key_id` (required when `server_side_encryption` is est to `"kms"`)
166+
167+
Specifies the CMK ID used for the server-side encryption using KMS.
168+
169+
* `auth` (required)
170+
171+
Specifies the name of the authenticator.
172+
173+
174+
### Authenticator Settings
175+
176+
```toml
177+
[auth.test]
178+
type = "inplace"
179+
180+
[auth.test.users.moriyoshi]
181+
password = "test"
182+
public_keys = """
183+
ssh-rsa AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
184+
ssh-rsa AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
185+
"""
186+
```
187+
188+
* `type` (required)
189+
190+
Specifies the authenticator implementation type. Currently `"inplace"` is the only valid value.
191+
192+
* `users` (required when `type` is `"inplace"`)
193+
194+
Contains user records as a dictionary.
195+
196+
197+
TBD.

0 commit comments

Comments
 (0)