Last active
January 19, 2022 17:22
Revisions
-
ruario revised this gist
Jan 19, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -94,8 +94,8 @@ Alternatively, if you can't be bothered with all that or find the thought proces ``` #!/usr/bin/env -S bash -eu if [ "${1:-}" = '-P' ]; then p="${@:1:2}" shift 2 fi eval l=\${$#} -
ruario revised this gist
Jan 19, 2022 . 1 changed file with 9 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -93,25 +93,20 @@ echo /users/r0/phlog/2022-01-14_One_shot_sftp.txt | nc sdf.org 70 Alternatively, if you can't be bothered with all that or find the thought process of how I arrived at this boring, here is a summary. ``` #!/usr/bin/env -S bash -eu if [ "$1" = '-P' ]; then p="$1 $2" shift 2 fi eval l=\${$#} if [[ "$l" == *:* ]]; then for f in "${@:1:$(($#-1))}"; do printf '%s\n' "put ${f// /\\ }" done | sftp ${p:-} "$l" else f="${1#*:}" printf '%s\n' "get ${f// /\\ } \"$2\"" | sftp ${p:-} "${1%%:*}" fi ``` ### Limitations -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -87,7 +87,7 @@ echo /users/r0/phlog/2022-01-14_One_shot_sftp.txt | nc sdf.org 70 ``` ``` (echo /users/r0/phlog/2022-01-16_One_shot_part2.txt; cat -) | telnet sdf.org 70 ``` Alternatively, if you can't be bothered with all that or find the thought process of how I arrived at this boring, here is a summary. -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -87,7 +87,7 @@ echo /users/r0/phlog/2022-01-14_One_shot_sftp.txt | nc sdf.org 70 ``` ``` (echo /users/r0/phlog/2022-01-16_One_shot_part2.txt; sleep 1) | telnet sdf.org 70 ``` Alternatively, if you can't be bothered with all that or find the thought process of how I arrived at this boring, here is a summary. -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -80,14 +80,14 @@ Years later I needed something like this again. See my 'phlog' (<gopher://sdf.or 1. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> 2. <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> Don't think you have a gopher client? You might… you can use `lynx` or even `curl`! Indeed, gopher is such a simple protocol, that if you have netcat (`nc`) or `telnet` installed, you could even hack them into fetching the content… ``` echo /users/r0/phlog/2022-01-14_One_shot_sftp.txt | nc sdf.org 70 ``` ``` (echo /users/r0/phlog/2022-01-16_One_shot_part2.txt ; sleep 1) | telnet sdf.org 70 ``` Alternatively, if you can't be bothered with all that or find the thought process of how I arrived at this boring, here is a summary. -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -75,7 +75,7 @@ P.S. Yes I know the man page specifically mentions the **-b** switch but some ba ## ✍ 2022-01-17 Years later I needed something like this again. See my 'phlog' (<gopher://sdf.org/1/users/r0/phlog>) posts for details. 1. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> 2. <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -80,14 +80,14 @@ Years later I needed something like this again. See my 'phlog' (<gopher://sdf.or 1. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> 2. <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> Don't think you have a gopher client? You might… you can use `lynx` or even `curl`! Indeed, gopher is such a simple protocol, that if you have netcat (`nc`) installed, your could also do this neat little hack… ``` echo /users/r0/phlog/2022-01-14_One_shot_sftp.txt | nc sdf.org 70 ``` ``` echo /users/r0/phlog/2022-01-16_One_shot_part2.txt | nc sdf.org 70 ``` Alternatively, if you can't be bothered with all that or find the thought process of how I arrived at this boring, here is a summary. -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -80,7 +80,7 @@ Years later I needed something like this again. See my 'phlog' (<gopher://sdf.or 1. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> 2. <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> Don't think you have a gopher client? You might… you can use `curl` or `lynx`. Indeed, gopher is such a simple protocol, that if you are using `bash` or `zsh` as your shell and have netcat (`nc`) installed, your could also do this neat little hack… ``` nc sdf.org 70 <<< /users/r0/phlog/2022-01-14_One_shot_sftp.txt @@ -90,7 +90,7 @@ nc sdf.org 70 <<< /users/r0/phlog/2022-01-14_One_shot_sftp.txt nc sdf.org 70 <<< /users/r0/phlog/2022-01-16_One_shot_part2.txt ``` Alternatively, if you can't be bothered with all that or find the thought process of how I arrived at this boring, here is a summary. ``` #!/bin/sh -eu -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -83,11 +83,11 @@ Years later I needed something like this again. See my 'phlog' (<gopher://sdf.or Don't think you have a gopher client? You might… use `lynx`. If you are using `bash` or `zsh` as your shell and have netcat `nc` installed, your could also do this neat little hack… ``` nc sdf.org 70 <<< /users/r0/phlog/2022-01-14_One_shot_sftp.txt ``` ``` nc sdf.org 70 <<< /users/r0/phlog/2022-01-16_One_shot_part2.txt ``` Alternatively, here is a summary. -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -80,7 +80,7 @@ Years later I needed something like this again. See my 'phlog' (<gopher://sdf.or 1. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> 2. <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> Don't think you have a gopher client? You might… use `lynx`. If you are using `bash` or `zsh` as your shell and have netcat `nc` installed, your could also do this neat little hack… ``` $ nc sdf.org 70 <<< /users/r0/phlog/2022-01-14_One_shot_sftp.txt -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -80,14 +80,14 @@ Years later I needed something like this again. See my 'phlog' (<gopher://sdf.or 1. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> 2. <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> Don't think you have a gopher client? You might… use `lynx`, or if you are using `bash` or `zsh` as yoru shell and have netcat `nc` installed, here is a little hack… ``` $ nc sdf.org 70 <<< /users/r0/phlog/2022-01-14_One_shot_sftp.txt ``` ``` $ nc sdf.org 70 <<< /users/r0/phlog/2022-01-16_One_shot_part2.txt ``` Alternatively, here is a summary. -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -77,8 +77,8 @@ P.S. Yes I know the man page specifically mentions the **-b** switch but some ba Years later I needed something like this again. See my 'phlog' (<gopher://sdf.org:70/1/users/r0/phlog>) posts for details. 1. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> 2. <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> Don't think you have a gopher client? You might… use `lynx`, or… -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -75,7 +75,7 @@ P.S. Yes I know the man page specifically mentions the **-b** switch but some ba ## ✍ 2022-01-17 Years later I needed something like this again. See my 'phlog' (<gopher://sdf.org:70/1/users/r0/phlog>) posts for details. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -75,12 +75,12 @@ P.S. Yes I know the man page specifically mentions the **-b** switch but some ba ## ✍ 2022-01-17 Years later I needed something like this again. See my 'phlog' (<gopher://sdf.org/1/users/r0/>) posts for details. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> Don't think you have a gopher client? You might… use `lynx`, or… ``` $ echo /users/r0/phlog/2022-01-14_One_shot_sftp.txt | nc sdf.org 70 | less -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -77,7 +77,7 @@ P.S. Yes I know the man page specifically mentions the **-b** switch but some ba Years later I needed something like this again. See my blog posts for details. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> Don't have a gopher client? You might… use `lynx`, or -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -77,8 +77,8 @@ P.S. Yes I know the man page specifically mentions the **-b** switch but some ba Years later I needed something like this again. See my blog posts for details. <gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt> <gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt> Don't have a gopher client? You might… use `lynx`, or -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 13 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -77,10 +77,20 @@ P.S. Yes I know the man page specifically mentions the **-b** switch but some ba Years later I needed something like this again. See my blog posts for details. 1. [2022-01-14 "One shot" sftp (simulating scp)](gopher://sdf.org/0/users/r0/phlog/2022-01-14_One_shot_sftp.txt) 2. [2022-01-16 "One shot" sftp (a step further)](gopher://sdf.org/0/users/r0/phlog/2022-01-16_One_shot_part2.txt) Don't have a gopher client? You might… use `lynx`, or ``` $ echo /users/r0/phlog/2022-01-14_One_shot_sftp.txt | nc sdf.org 70 | less ``` ``` $ echo /users/r0/phlog/2022-01-16_One_shot_part2.txt | nc sdf.org 70 | less ``` Alternatively, here is a summary. ``` #!/bin/sh -eu -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -80,7 +80,7 @@ Years later I needed something like this again. See my blog posts for details. 1. [2022-01-14 "One shot" sftp (simulating scp)](https://ruario.flounder.online/gemlog/2022-01-14_One_shot_sftp.gmi) 2. [2022-01-16 "One shot" sftp (a step further)](https://ruario.flounder.online/gemlog/2022-01-16_One_shot_part2.gmi) If those posts are too long/boring, and you do not want to read my thought process, here is a summary. ``` #!/bin/sh -eu -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -106,7 +106,7 @@ esac ### Limitations * You can't download multiple files like so, `server:\{file1,file2\} .`—I am not sure how many people knew about that scp feature anyway. You can still grab more than one file at a time using wild cards however, e.g. `server:file\?.txt .` * You can't download to a directory with colon in the name, or 'on-the-fly' rename a download to filename that contains a colon. * You can't rename a file on upload like so, `file1 server:file2`—you can still copy to an already present remote directory, e.g. `file1 server:dir`. * Only the `-P` (port) option is supported and (if you want to use it) it must be the first argument with a space to separate it from the port number. -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -75,12 +75,12 @@ P.S. Yes I know the man page specifically mentions the **-b** switch but some ba ## ✍ 2022-01-17 Years later I needed something like this again. See my blog posts for details. 1. [2022-01-14 "One shot" sftp (simulating scp)](https://ruario.flounder.online/gemlog/2022-01-14_One_shot_sftp.gmi) 2. [2022-01-16 "One shot" sftp (a step further)](https://ruario.flounder.online/gemlog/2022-01-16_One_shot_part2.gmi) If that is too long, and you do not want to read my thought process, here is a summary. ``` #!/bin/sh -eu -
ruario revised this gist
Jan 17, 2022 . 1 changed file with 41 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -71,4 +71,44 @@ done **Note:** *Using sftp in this way requires non-interactive authentication using keys to be configured. You can set `-oBatchMode=no` to use password authentication but this would be cumbersome when uploading multiple files using the above example, as you would be prompted for a password before each file is uploaded.* P.S. Yes I know the man page specifically mentions the **-b** switch but some basic examples help. ## ✍ 2022-01-17 Years latter I needed something like this again and rethought and tested it. See my blog posts for details. 1. [2022-01-14 "One shot" sftp (simulating scp)](https://ruario.flounder.online/gemlog/2022-01-14_One_shot_sftp.gmi) 2. [2022-01-16 "One shot" sftp (a step further)](https://ruario.flounder.online/gemlog/2022-01-16_One_shot_part2.gmi) If that is too long, and you do not want to read my thought process. Here is the summary. ``` #!/bin/sh -eu if [ "$1" = '-P' ]; then p="$1 $2" shift 2 fi eval l=\${$#} s () { printf '%s\n' "$1" | sed 's/ /\\ /g'; } case "$l" in *:*) c=0; t="$(($#-1))" for f in "$@"; do if [ "$c" -lt "$t" ]; then printf '%s\n' "put $(s "$f")" c="$(($c+1))" fi done | sftp ${p:-} "$l" ;; *) printf '%s\n' "get $(s "${1#*:}") \"$2\"" | sftp ${p:-} "${1%%:*}" ;; esac ``` ### Limitations You can't download multiple files like so, `server:\{file1,file2\} .`—I am not sure how many people knew about that scp feature anyway. You can still grab more than one file at a time using wild cards however, e.g. `server:file\?.txt .` * You can't download to a directory with colon in the name, or 'on-the-fly' rename a download to filename that contains a colon. * You can't rename a file on upload like so, `file1 server:file2`—you can still copy to an already present remote directory, e.g. `file1 server:dir`. * Only the `-P` (port) option is supported and (if you want to use it) it must be the first argument with a space to separate it from the port number. * You can't do server to server copies—another feature that might not even be widely known or used. * If certain unusual characters actually appear in filenames—and are not intended as wildcards—they would need to be double escaped (e.g. a file named `file*1`, would need to be uploaded as `file1 server:"file\*1"`). -
ruario revised this gist
Jun 30, 2014 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,7 +53,13 @@ Give this a suitable name (e.g. upload-sftp) and use it as follows: upload-sftp server:path file* ``` Using Bash instead of Bourne Shell would allow you to specify *server:path* as the last option (like scp), i.e.: ```bash upload-sftp file* server:path ``` To do that, use the following: ```bash #!/bin/bash -
ruario revised this gist
Jun 30, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,7 +53,7 @@ Give this a suitable name (e.g. upload-sftp) and use it as follows: upload-sftp server:path file* ``` If you would prefer specify *server:path* as the last option (like scp), this bash script should do the trick: ```bash #!/bin/bash -
ruario revised this gist
Jun 30, 2014 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,6 +53,16 @@ Give this a suitable name (e.g. upload-sftp) and use it as follows: upload-sftp server:path file* ``` If you would prefer specify *server:path* as the last option, this bash script should do the trick: ```bash #!/bin/bash eval s=\$$# for f in "${@:1:$(($#-1))}"; do printf "progress\nput $f" | sftp -b- "$s" || exit 1 done ``` **Note:** *Using sftp in this way requires non-interactive authentication using keys to be configured. You can set `-oBatchMode=no` to use password authentication but this would be cumbersome when uploading multiple files using the above example, as you would be prompted for a password before each file is uploaded.* P.S. Yes I know the man page specifically mentions the **-b** switch but some basic examples help. -
ruario revised this gist
Jun 30, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,4 +55,4 @@ upload-sftp server:path file* **Note:** *Using sftp in this way requires non-interactive authentication using keys to be configured. You can set `-oBatchMode=no` to use password authentication but this would be cumbersome when uploading multiple files using the above example, as you would be prompted for a password before each file is uploaded.* P.S. Yes I know the man page specifically mentions the **-b** switch but some basic examples help. -
ruario revised this gist
Jun 30, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,6 +53,6 @@ Give this a suitable name (e.g. upload-sftp) and use it as follows: upload-sftp server:path file* ``` **Note:** *Using sftp in this way requires non-interactive authentication using keys to be configured. You can set `-oBatchMode=no` to use password authentication but this would be cumbersome when uploading multiple files using the above example, as you would be prompted for a password before each file is uploaded.* P.S. Yes I know the man page specifically mentions the **-b** switch but a few basic examples always help! -
ruario revised this gist
Jun 30, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,9 +14,9 @@ Match User yourusername ForceCommand internal-sftp ``` Then attempting to connect via scp, would result in the error message: *"This service allows sftp connections only."* In such a case, you can simulate *basic* scp behaviour as follows: ```bash echo put file | sftp -b- server:path -
ruario revised this gist
Jun 30, 2014 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ Normally if you want to quickly send a file to a remote directory on an ssh server as a *one liner* or within a script, the following would suffice: ```bash scp file server:path ``` @@ -18,19 +18,19 @@ Attempting to connect to machine configured like this via scp, will result in th In that case, you can simulate basic scp behaviour as follows: ```bash echo put file | sftp -b- server:path ``` Alternatively, if you need to display the progress of the file as it uploads: ```bash printf "progress\nput file" | sftp -b- server:path ``` If you need to upload multiple files, you could use a for loop: ```bash for f in file1 file2 file3; do echo put "$f" | sftp -b- server:path; done ``` @@ -49,7 +49,7 @@ done Give this a suitable name (e.g. upload-sftp) and use it as follows: ```bash upload-sftp server:path file* ``` -
ruario revised this gist
Jun 30, 2014 . 1 changed file with 30 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,43 +1,57 @@ Normally if you want to quickly send a file to a remote directory on an ssh server as a *one liner* or within a script, the following would suffice: ``` scp file server:path ``` Occasionally, you may come across a server that only has sftp enabled and not scp. For example if the OpenSSH server you were connecting to was configured as follows: ``` Subsystem sftp internal-sftp Match User yourusername ChrootDirectory /home/%u ForceCommand internal-sftp ``` Attempting to connect to machine configured like this via scp, will result in the error message: *"This service allows sftp connections only."* In that case, you can simulate basic scp behaviour as follows: ``` echo put file | sftp -b- server:path ``` Alternatively, if you need to display the progress of the file as it uploads: ``` printf "progress\nput file" | sftp -b- server:path ``` If you need to upload multiple files, you could use a for loop: ``` for f in file1 file2 file3; do echo put "$f" | sftp -b- server:path; done ``` (If this example **file\*** would also have worked as a wildcard in place of **file1 file2 file3**). You can combine all of the above to make a very simple upload script like so: ```bash #!/bin/sh s="$1" shift 1 for f in "$@"; do printf "progress\nput $f" | sftp -b- "$s" || exit 1 done ``` Give this a suitable name (e.g. upload-sftp) and use it as follows: ``` upload-sftp server:path file* ``` **Note:** *Using sftp in this way requires non-interactive authentication using keys to be configured. You can set "-oBatchMode=no" to use password authentication but this would be cumbersome when uploading multiple files using the above example, as you would be prompted for a password before each file is uploaded.* -
ruario revised this gist
Jun 30, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ Occasionally, you may come across a server that only has sftp enabled and not sc ChrootDirectory /home/%u ForceCommand internal-sftp Attempting to connect to machine configured like this via scp, will result in the error message: *"This service allows sftp connections only."* In that case, you can simulate basic scp behaviour as follows:
NewerOlder