🖥

#Linux の curl を ssh proxy を経由で実行する

2019/10/31に公開

なにやらsshでportを立てて、それ経由でcurlできるっぽい

ssh -D 8080 -f -C -q -N user@remote.host
curl -x socks5h://0:8080 https://example.com

curl HTTPS via an SSH proxy - Stack Overflow

ssh -D

アドレスをポートにバインドする

     -D [bind_address:]port
             Specifies a local ``dynamic'' application-level port forwarding.
             This works by allocating a socket to listen to port on the local
             side, optionally bound to the specified bind_address.  Whenever a
             connection is made to this port, the connection is forwarded over
             the secure channel, and the application protocol is then used to
             determine where to connect to from the remote machine.  Currently
             the SOCKS4 and SOCKS5 protocols are supported, and ssh will act
             as a SOCKS server.  Only root can forward privileged ports.
             Dynamic port forwardings can also be specified in the configura-
             tion file.

ssh -f

バックグラウンドでなんとか

     -f      Requests ssh to go to background just before command execution.
             This is useful if ssh is going to ask for passwords or
             passphrases, but the user wants it in the background.  This
             implies -n.  The recommended way to start X11 programs at a
             remote site is with something like ssh -f host xterm.

             If the ExitOnForwardFailure configuration option is set to
             ``yes'', then a client started with -f will wait for all remote
             port forwards to be successfully established before placing
             itself in the background.

ssh -C

圧縮がなんとか

     -C      Requests compression of all data (including stdin, stdout,
             stderr, and data for forwarded X11, TCP and UNIX-domain connec-
             tions).  The compression algorithm is the same used by gzip(1).
             Compression is desirable on modem lines and other slow connec-
             tions, but will only slow down things on fast networks.  The
             default value can be set on a host-by-host basis in the configu-
             ration files; see the Compression option.

ssh -q

お静かにモード

     -q      Quiet mode.  Causes most warning and diagnostic messages to be
             suppressed.

ssh -N

コマンド実行しない
portを待ち受ける時に便利らしい

     -N      Do not execute a remote command.  This is useful for just for-
             warding ports.

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/2646

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-10-31

Discussion