
명령줄에서 쉽고 빠른 파일 공유.
인증되지 않은 X-Forwarded-For 헤더 스푸핑을 통한 IP 필터 및 HTTP 인증 우회
쉬운 명령줄 파일 공유. 이 코드는 자신의 인스턴스를 생성하는 데 필요한 모든 것을 갖춘 서버를 포함하고 있습니다.
Transfer.sh는 현재 s3 (Amazon S3), gdrive (Google Drive), storj (Storj) 프로바이더 및 로컬 파일 시스템 (local)을 지원합니다.
@stefanbenten은 이 저장소의 관리자이며, 동시에 이 저장소에 있는 소프트웨어의 잘 알려진 공개 설치를 호스팅하는 사람입니다.
두 가지는 서로 관련이 없으며, 이 저장소는 공개 설치에 대한 요청이나 문제를 제기하는 장소가 아닙니다.
보안상의 이유로, 저장소 내에 있는 소프트웨어의 제3자 공개 설치는 저장소 자체에 광고되거나 언급되지 않습니다.
관리자로서의 제(@aspacca) 공식 입장은, 이 소프트웨어를 사용하려면 직접 설치를 호스팅해야 한다는 것입니다.
이 섹션은 transfer.sh를 사용하는 방법을 설명합니다.
$ curl -v --upload-file ./hello.txt https://transfer.sh/hello.txt
<br />
### 암호화 및 업로드```bash
$ gpg --armor --symmetric --output - /tmp/hello.txt | curl --upload-file - https://transfer.sh/test.txt
$ curl https://transfer.sh/1lDau/test.txt | gpg --decrypt --output /tmp/hello.txt
<br />
### Virustotal에 업로드```bash
$ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/virustotal
$ curl -X DELETE
<br />
---
<br />
## 요청 헤더
이 섹션에서는 curl로 요청 헤더를 처리하는 방법을 설명합니다:
<br />
### Max-Downloads```bash
$ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H "Max-Downloads: 1" # Limit the number of downloads
$ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H "Max-Days: 1" # Set the number of days before deletion
<br />
### X-Encrypt-Password
#### 경고: 이 기능은 자체 호스팅 서버에서만 사용하십시오: 타사 서비스의 서버 측 암호화를 신뢰하는 것은 본인의 책임입니다.```bash
$ curl --upload-file ./hello.txt https://your-transfersh-instance.tld/hello.txt -H "X-Encrypt-Password: test" # Encrypt the content server side with AES256 using "test" as password
$ curl https://your-transfersh-instance.tld/BAYh0/hello.txt -H "X-Decrypt-Password: test" # Decrypt the content server side with AES256 using "test" as password
<br />
---
<br />
## 응답 헤더
이 섹션에서는 응답 헤더를 처리하는 방법을 설명합니다:
<br />
### X-Url-Delete
파일 삭제를 요청하는 데 사용되며 응답 헤더로 반환되는 URL:<br />
---
<br />
## 응답 헤더
이 섹션에서는 응답 헤더를 처리하는 방법을 설명합니다:
<br />
### X-Url-Delete
파일 삭제를 요청하는 데 사용되며 응답 헤더로 반환되는 URL:```bash
curl -sD - --upload-file ./hello.txt https://transfer.sh/hello.txt | grep -i -E 'transfer\.sh|x-url-delete'
x-url-delete: https://transfer.sh/hello.txt/BAYh0/hello.txt/PDw0NHPcqU
https://transfer.sh/hello.txt/BAYh0/hello.txt
좋은 사용 예제는 examples.md에서 확인하세요.
직접 다운로드 링크 생성:
https://transfer.sh/1lDau/test.txt --> https://transfer.sh/get/1lDau/test.txt
인라인 파일:
https://transfer.sh/1lDau/test.txt --> https://transfer.sh/inline/1lDau/test.txt
Let's Encrypt 인증서를 사용하여 TLS를 사용하려면 lets-encrypt-hosts를 도메인으로 설정하고, tls-listener를 :443으로 설정하고 force-https를 활성화하세요.
자체 인증서를 사용하여 TLS를 사용하려면 tls-listener를 :443, force-https, tls-cert-file 및 tls-private-key를 설정하세요.
GO111MODULE로 전환됨```bash go run main.go --provider=local --listener :8080 --temp-path=/tmp/ --basedir=/tmp/
<br />
---
<br />
## 빌드```bash
$ git clone [email protected]:dutchcoders/transfer.sh.git
$ cd transfer.sh
$ go build -o transfersh main.go
쉬운 배포를 위해 공식 Docker 컨테이너를 만들었습니다. 두 가지 변형이 있으며, 프로세스를 실행하는 사용자만 다릅니다.
기본 컨테이너는 root로 실행됩니다:
[!WARNING] WatchTower 또는 유사한 도구에
latest태그를 사용하는 것은 권장되지 않습니다.latest태그는 출시되지 않은 개발자 빌드, 테스트 빌드, 이전 버전의 패치 릴리스를 참조할 수 있습니다. transfer.sh가 주요 또는 부 버전 태그를 지원할 때까지 실제 버전 태그를 사용하세요.```bash docker run --publish 8080:8080 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/
<br />
### 루트 없음
`-noroot` 태그는 애플리케이션이 손상될 경우 공격 표면을 줄이기 위해 최소 권한으로 실행되는 이미지 빌드를 나타냅니다.
> [!NOTE]
> `-noroot` 사용이 **권장**됩니다
<br />
접미사 `-noroot`가 붙은 이미지는 UID와 GID로 `5000`을 사용합니다:```bash
docker run --publish 8080:8080 dutchcoders/transfer.sh:latest-noroot --provider local --basedir /tmp/
[!NOTE] 개발 이력 상세 정보:
컨테이너를 직접 빌드할 수도 있습니다. 이를 통해 NFS 마운트 사용 시 등 어떤 UID/GID를 사용할지 선택할 수 있습니다.```bash
docker build -t transfer.sh-noroot --build-arg RUNAS=doesntmatter --build-arg PUID=1337 --build-arg PGID=1338 .
<br />
---
<br />
## S3 사용법
AWS S3 버킷을 사용하는 방법은 다음과 같습니다. 다음 옵션을 지정하기만 하면 됩니다.
- provider `--provider s3`
- aws-access-key _(플래그 또는 환경 변수 `AWS_ACCESS_KEY`를 통해)_
- aws-secret-key _(플래그 또는 환경 변수 `AWS_SECRET_KEY`를 통해)_
- bucket _(플래그 또는 환경 변수 `BUCKET`를 통해)_
- s3-region _(플래그 또는 환경 변수 `S3_REGION`을 통해)_
s3-region을 지정하면 올바른 엔드포인트가 자동으로 사용되므로 엔드포인트 URL을 설정할 필요가 없습니다.
<br />
### 커스텀 S3 제공자
AWS가 아닌 커스텀 S3 제공자를 사용하려면 클라우드 제공자가 정의한 엔드포인트를 지정해야 합니다.
<br />
---
<br />
## Storj 네트워크 제공자
Storj 네트워크를 스토리지 제공자로 사용하려면 다음 플래그를 지정해야 합니다.
- provider `--provider storj`
- storj-access _(플래그 또는 환경 변수 STORJ_ACCESS를 통해)_
- storj-bucket _(플래그 또는 환경 변수 STORJ_BUCKET를 통해)_
<br />
### 버킷 및 범위 생성
준비 과정에서 액세스 권한(또는 uplink 구성에서 복사)과 버킷을 생성해야 합니다.
시작하려면 계정에 로그인하고 액세스 권한 메뉴로 이동하여 오른쪽 상단의 마법사를 시작하세요.
원하는 액세스 권한 이름을 입력하고 *다음*을 클릭한 후 필요/선호에 따라 제한합니다.
이후 CLI 또는 브라우저에서 계속 진행합니다. 다음으로 암호화 키로 사용될 암호문을 입력하라는 메시지가 표시됩니다.
**안전한 곳에 저장해야 합니다. 암호문이 없으면 파일을 복호화할 수 없습니다!**
그런 다음 액세스 권한을 복사하고 transfer.sh 엔드포인트를 시작하면 됩니다.
보안 강화를 위해 액세스 권한과 버킷 이름을 모두 환경 변수로 제공하는 것이 좋습니다.
예시:```
export STORJ_BUCKET=<BUCKET NAME>
export STORJ_ACCESS=<ACCESS GRANT>
transfer.sh --provider storj
Google Drive를 사용하려면 다음 옵션을 지정해야 합니다:
console.cloud.google.com에서 OAuth 클라이언트 ID를 생성하고, 파일을 다운로드하여 안전한 디렉토리에 저장해야 합니다.
go run main.go --provider gdrive --basedir /tmp/ --gdrive-client-json-filepath /[credential_dir] --gdrive-local-config-path [directory_to_save_config] transfer() (if [ $# -eq 0 ]; then printf "인수가 지정되지 않았습니다.\n사용법:\n transfer <파일|디렉토리>\n ... | transfer <파일_이름>\n">&2; return 1; fi; file_name=$(basename "$1"); if [ -t 0 ]; then file="$1"; if [ ! -e "$file" ]; then echo "$file: 해당 파일 또는 디렉토리가 없습니다">&2; return 1; fi; if [ -d "$file" ]; then cd "$file" || return 1; file_name="$file_name.zip"; set -- zip -r -q - .; else set -- cat "$file"; fi; else set -- cat; fi; url=$("$@" | curl --silent --show-error --progress-bar --upload-file "-" "https://transfer.sh/$file_name"); echo "$url"; )```
<br />
#### Now you can use transfer function
$ transfer hello.txt```
transfer()
{
local file
declare -a file_array
file_array=("${@}")
if [[ "${file_array[@]}" == "" || "${1}" == "--help" || "${1}" == "-h" ]]
then
echo "${0} - Upload arbitrary files to \"transfer.sh\"."
echo ""
echo "Usage: ${0} [options] [<file>]..."
echo ""
echo "OPTIONS:"
echo " -h, --help"
echo " show this message"
echo ""
echo "EXAMPLES:"
echo " Upload a single file from the current working directory:"
echo " ${0} \"image.img\""
echo ""
echo " Upload multiple files from the current working directory:"
echo " ${0} \"image.img\" \"image2.img\""
echo ""
echo " Upload a file from a different directory:"
echo " ${0} \"/tmp/some_file\""
echo ""
echo " Upload all files from the current working directory. Be aware of the webserver's rate limiting!:"
echo " ${0} *"
echo ""
echo " Upload a single file from the current working directory and filter out the delete token and download link:"
echo " ${0} \"image.img\" | awk --field-separator=\": \" '/Delete token:/ { print \$2 } /Download link:/ { print \$2 }'"
echo ""
echo " Show help text from \"transfer.sh\":"
echo " curl --request GET \"https://transfer.sh\""
return 0
else
for file in "${file_array[@]}"
do
if [[ ! -f "${file}" ]]
then
echo -e "\e[01;31m'${file}' could not be found or is not a file.\e[0m" >&2
return 1
fi
done
unset file
fi
local upload_files
local curl_output
local awk_output
du -c -k -L "${file_array[@]}" >&2
# be compatible with "bash"
if [[ "${ZSH_NAME}" == "zsh" ]]
then
read $'upload_files?\e[01;31mDo you really want to upload the above files ('"${#file_array[@]}"$') to "transfer.sh"? (Y/n): \e[0m'
elif [[ "${BASH}" == *"bash"* ]]
then
read -p $'\e[01;31mDo you really want to upload the above files ('"${#file_array[@]}"$') to "transfer.sh"? (Y/n): \e[0m' upload_files
fi
case "${upload_files:-y}" in
"y"|"Y")
# for the sake of the progress bar, execute "curl" for each file.
# the parameters "--include" and "--form" will suppress the progress bar.
for file in "${file_array[@]}"
do
# show delete link and filter out the delete token from the response header after upload.
# it is important to save "curl's" "stdout" via a subshell to a variable or redirect it to another command,
# which just redirects to "stdout" in order to have a sane output afterwards.
# the progress bar is redirected to "stderr" and is only displayed,
# if "stdout" is redirected to something; e.g. ">/dev/null", "tee /dev/null" or "| <some_command>".
# the response header is redirected to "stdout", so redirecting "stdout" to "/dev/null" does not make any sense.
# redirecting "curl's" "stderr" to "stdout" ("2>&1") will suppress the progress bar.
curl_output=$(curl --request PUT --progress-bar --dump-header - --upload-file "${file}" "https://transfer.sh/")
awk_output=$(awk \
'gsub("\r", "", $0) && tolower($1) ~ /x-url-delete/ \
{
delete_link=$2;
print "Delete command: curl --request DELETE " "\""delete_link"\"";
gsub(".*/", "", delete_link);
delete_token=delete_link;
print "Delete token: " delete_token;
}
END{
print "Download link: " $0;
}' <<< "${curl_output}")
# return the results via "stdout", "awk" does not do this for some reason.
echo -e "${awk_output}\n"
# avoid rate limiting as much as possible; nginx: too many requests.
if (( ${#file_array[@]} > 4 ))
then
sleep 5
fi
done
;;
"n"|"N")
return 1
;;
*)
echo -e "\e[01;31mWrong input: '${upload_files}'.\e[0m" >&2
return 1
esac
}```
</p></details>
#### Sample output
```bash
$ ls -lh
total 20M
-rw-r--r-- 1 <some_username> <some_username> 10M Apr 4 21:08 image.img
-rw-r--r-- 1 <some_username> <some_username> 10M Apr 4 21:08 image2.img
$ transfer image*
10240K image2.img
10240K image.img
20480K total
위 파일(2개)을(를) "transfer.sh"에 정말 업로드하시겠습니까? (Y/n):
######################################################################################################################################################################################################################################## 100.0%
삭제 명령: curl --request DELETE "https://transfer.sh/wJw9pz/image2.img/mSctGx7pYCId"
삭제 토큰: mSctGx7pYCId
다운로드 링크: https://transfer.sh/wJw9pz/image2.img
######################################################################################################################################################################################################################################## 100.0%
삭제 명령: curl --request DELETE "https://transfer.sh/ljJc5I/image.img/nw7qaoiKUwCU"
삭제 토큰: nw7qaoiKUwCU
다운로드 링크: https://transfer.sh/ljJc5I/image.img
$ transfer "image.img" | awk --field-separator=": " '/Delete token:/ { print $2 } /Download link:/ { print $2 }'
10240K image.img
10240K total
위 파일(1개)을(를) "transfer.sh"에 정말 업로드하시겠습니까? (Y/n):
######################################################################################################################################################################################################################################## 100.0%
tauN5dE3fWJe
https://transfer.sh/MYkuqn/image.img```
<br />
---
<br />
## Contributions
Contributions are welcome.
<br />
---
<br />
## Creators
**Remco Verhoef**
- <https://twitter.com/remco_verhoef>
- <https://twitter.com/dutchcoders>
**Uvis Grinfelds**
<br />
---
<br />
## Maintainers
- **Andrea Spacca**
- **Stefan Benten**
<br />
---
<br />
## Copyright and License
Code and documentation copyright 2011-2018 Remco Verhoef.
Code and documentation copyright 2018-2020 Andrea Spacca.
Code and documentation copyright 2020- Andrea Spacca and Stefan Benten.
Code released under [the MIT license](https://github.com/dutchcoders/transfer.sh/blob/HEAD/LICENSE).
| 매개변수 | 설명 | 값 | 환경 변수 |
|---|
| listener | http에 사용할 포트 (:80) | LISTENER | |
| profile-listener | 프로파일러에 사용할 포트 (:6060) | PROFILE_LISTENER | |
| force-https | https로 리디렉션 | false | FORCE_HTTPS |
| tls-listener | https에 사용할 포트 (:443) | TLS_LISTENER | |
| tls-listener-only | TLS 리스너만 활성화하는 플래그 | TLS_LISTENER_ONLY | |
| tls-cert-file | TLS 인증서 경로 | TLS_CERT_FILE | |
| tls-private-key | TLS 개인 키 경로 | TLS_PRIVATE_KEY | |
| http-auth-user | 업로드 시 기본 HTTP 인증 사용자 | HTTP_AUTH_USER | |
| http-auth-pass | 업로드 시 기본 HTTP 인증 비밀번호 | HTTP_AUTH_PASS | |
| http-auth-htpasswd | 업로드 시 기본 HTTP 인증을 위한 htpasswd 파일 경로 | HTTP_AUTH_HTPASSWD | |
| http-auth-ip-whitelist | 인증 없이 업로드가 허용된 IP 주소 쉼표로 구분된 목록 | HTTP_AUTH_IP_WHITELIST | |
| virustotal-key | VirusTotal API 키 | VIRUSTOTAL_KEY | |
| ip-whitelist | 서비스 접속이 허용된 IP 주소 쉼표로 구분된 목록 | IP_WHITELIST | |
| ip-blacklist | 서비스 접속이 허용되지 않은 IP 주소 쉼표로 구분된 목록 | IP_BLACKLIST | |
| temp-path | 임시 폴더 경로 | 시스템 임시 | TEMP_PATH |
| web-path | 정적 웹 파일 경로 (개발 또는 사용자 지정 프런트엔드용) | WEB_PATH | |
| proxy-path | 서비스가 프록시 뒤에서 실행될 때 경로 접두사 (/ 접두사는 제거됨) | PROXY_PATH | |
| proxy-port | 서비스가 프록시 뒤에서 실행될 때 프록시 포트 | PROXY_PORT | |
| email-contact | 프런트엔드용 이메일 연락처 | EMAIL_CONTACT | |
| ga-key | 프런트엔드용 Google 애널리틱스 키 | GA_KEY | |
| provider | 사용할 저장소 제공자 | (s3, storj, gdrive 또는 local) | |
| uservoice-key | 프런트엔드용 UserVoice 키 | USERVOICE_KEY | |
| aws-access-key | AWS 액세스 키 | AWS_ACCESS_KEY | |
| aws-secret-key | AWS 비밀 키 | AWS_SECRET_KEY | |
| bucket | AWS 버킷 | BUCKET | |
| s3-endpoint | 사용자 지정 S3 엔드포인트 | S3_ENDPOINT | |
| s3-region | S3 버킷 리전 | eu-west-1 | S3_REGION |
| s3-no-multipart | S3 멀티파트 업로드 비활성화 | false | S3_NO_MULTIPART |
| s3-path-style | Minio에 필요한 경로 스타일 URL 강제 | false | S3_PATH_STYLE |
| storj-access | 프로젝트 액세스 | STORJ_ACCESS | |
| storj-bucket | 프로젝트 내에서 사용할 버킷 | STORJ_BUCKET | |
| basedir | 로컬/gdrive 제공자용 저장소 경로 | BASEDIR | |
| gdrive-client-json-filepath | GDrive 제공자용 OAuth 클라이언트 JSON 설정 파일 경로 | GDRIVE_CLIENT_JSON_FILEPATH | |
| gdrive-local-config-path | GDrive 제공자용 로컬 transfer.sh 설정 캐시 저장 경로 | GDRIVE_LOCAL_CONFIG_PATH | |
| gdrive-chunk-size | GDrive 업로드 청크 크기 (MB), 사용 가능한 메모리보다 작아야 함 (8MB) | GDRIVE_CHUNK_SIZE | |
| lets-encrypt-hosts | Let's Encrypt 인증서에 사용할 호스트 (쉼표로 구분) | HOSTS | |
| log | 로그 파일 경로 | LOG | |
| cors-domains | CORS용 도메인 쉼표로 구분 목록, 설정 시 CORS 활성화 | CORS_DOMAINS | |
| clamav-host | ClamAV 기능용 호스트 | CLAMAV_HOST | |
| perform-clamav-prescan | ClamAV를 사용하여 모든 업로드 사전 검사 (clamav-host는 로컬 clamd 유닉스 소켓이어야 함) | PERFORM_CLAMAV_PRESCAN | |
| rate-limit | 분당 요청 수 | RATE_LIMIT | |
| max-upload-size | 최대 업로드 크기 (KB) | MAX_UPLOAD_SIZE | |
| purge-days | 업로드가 자동으로 제거되는 일 수 | PURGE_DAYS | |
| purge-interval | 자동 제거 실행 간격 (시간) (S3 및 Storj 제외) | PURGE_INTERVAL | |
| random-token-length | 업로드 경로용 무작위 토큰 길이 (삭제 경로는 두 배) | 6 | RANDOM_TOKEN_LENGTH |
| 이름 | 사용법 |
|---|
| latest | 최신 CI 빌드, nightly, 커밋, 태그 등일 수 있음. |
| latest-noroot | 최신 CI 빌드, nightly, 커밋, 태그 등일 수 있음. [no root] 사용 |
| nightly | 매일 UTC 자정에 예약된 CI 빌드 |
| nightly-noroot | 매일 UTC 자정에 예약된 CI 빌드, [no root] 사용 |
| edge | main에 커밋될 때마다 최신 CI 빌드 |
| edge-noroot | main에 커밋될 때마다 최신 CI 빌드, [no root] 사용 |
vx.y.z | 릴리스 태그 이후 CI 빌드 |
vx.y.z-noroot | 릴리스 태그 이후 CI 빌드, [no root] 사용 |