Differences
This shows you the differences between the selected revisions of the page.
| guide_tunnel 2009-11-22 | guide_tunnel 2026-06-02 (current) | ||
| Line 1: | Line 1: | ||
| - | ====== Connect to FTP/SFTP Server Which Can Be Accessed via Another Server Only ====== | + | ====== Connect to FTP/SFTP server which can be accessed via another server only ====== |
| //This guide contains simplified description of connecting to FTP or SFTP server via tunnel with WinSCP. You may want to see [[tunneling|documentation of the tunneling functionality]] instead//. | //This guide contains simplified description of connecting to FTP or SFTP server via tunnel with WinSCP. You may want to see [[tunneling|documentation of the tunneling functionality]] instead//. | ||
| + | |||
| + | ===== Before Starting ===== | ||
| Before starting you should: | Before starting you should: | ||
| Line 9: | Line 11: | ||
| One possible approach is to setup SSH [[tunneling|tunnel]] and connect through the tunnel. | One possible approach is to setup SSH [[tunneling|tunnel]] and connect through the tunnel. | ||
| - | For simple cases, you can setup tunnel directly in WinSCP.·For more complex cases (non-default SSH settings, multiple hops, FTP protocol, etc.) you need to setup tunnel using external tool. Example of such tool is [[&url(putty)|PuTTY SSH client]]. For more information see [[http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter3.html#using-port-forwarding|PuTTY documentation on port forwarding]]. | + | For simple cases, you can [[ui_login_tunnel|setup tunnel directly in WinSCP]]. |
| + | |||
| + | For more complex cases (non-default %%SSH%% settings, multiple hops, FTP protocol, etc.) you need to setup tunnel using external tool. Example of such tool is [[&url(putty)|PuTTY SSH client]] or [[https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter7.html|Plink]]. For more information see [[&url(puttydoc)/Chapter3.html#using-port-forwarding|PuTTY documentation on port forwarding]]. | ||
| In the text, //Server B// stays for the target server and //Server A// stays for the server thru which you need to connect. | In the text, //Server B// stays for the target server and //Server A// stays for the server thru which you need to connect. | ||
| - | ===== Setting up tunnel in WinSCP ===== | + | ===== [[tunnel_winscp]] Setting up tunnel in WinSCP ===== |
| - | See //[[ui_login_tunnel|Tunnel tab]]// on Login dialog. | + | See //[[ui_login_tunnel|Tunnel page]]// on Advanced Site Settings dialog. |
| - | ===== Setting up tunnel using PuTTY for SFTP/SCP session ===== | + | ===== [[tunnel_two]] Setting up two hop tunnel using Plink ===== |
| + | |||
| + | You can use Plink to implement the first hop by using the following [[ui_login_proxy#command|//Local proxy command//]]:((For details, see [[https://superuser.com/q/477312/213663#1489111|Using WinSCP with SFTP server and two SSH tunnel hops]].)) | ||
| + | |||
| + | <code> | ||
| + | plink.exe %user@%proxyhost -nc %host:%port | ||
| + | </code> | ||
| + | |||
| + | For the second hop, use //[[ui_login_tunnel|Tunnel page]]// as above. | ||
| + | |||
| + | ===== [[tunnel_putty]] Setting up tunnel using PuTTY for SFTP/SCP session ===== | ||
| Note that this is for illustration only, such a simple tunnel can be setup directly in WinSCP. | Note that this is for illustration only, such a simple tunnel can be setup directly in WinSCP. | ||
| ==== Setting up the tunnel ==== | ==== Setting up the tunnel ==== | ||
| - | In PuTTY configure a session for //Server A//. I.e. particularly fill in //Host Name//. Then switch to //Connection > SSH > Tunnels// tab. And add new forwarded port: | + | In PuTTY configure a session for //Server A//. I.e. particularly fill in //Host Name//. Then switch to //Connection > SSH > Tunnels// page. And add new forwarded port: |
| * //Source port//: Any free local port, typically above 3000. Example: 3111. | * //Source port//: Any free local port, typically above 3000. Example: 3111. | ||
| * //Destination//: Hostname and port of the //Server B// separated by colon (the same information you would fill on //Session// dialog of WinSCP if you were connecting directly). The port will typically be SSH port 22. Example: example.com:22. | * //Destination//: Hostname and port of the //Server B// separated by colon (the same information you would fill on //Session// dialog of WinSCP if you were connecting directly). The port will typically be SSH port 22. Example: example.com:22. | ||
| Line 30: | Line 44: | ||
| putty.exe <Server A> -L 3111:<Server B>:22 | putty.exe <Server A> -L 3111:<Server B>:22 | ||
| - | ==== Connecting through the tunnel ==== | + | ==== [[tunnel_putty_connecting]] Connecting through the tunnel ==== |
| In WinSCP configure an SFTP/SCP session for //Server B//. Most settings will be like if you connect to //Server B// directly (username, password, etc.). The only differences are: | In WinSCP configure an SFTP/SCP session for //Server B//. Most settings will be like if you connect to //Server B// directly (username, password, etc.). The only differences are: | ||
| - | * //Host name//: Fill in "localhost". | + | * //Hostname//: Fill in "localhost". |
| * //Port number//: Fill in //Source port// of forwarded port. Example: 3111. | * //Port number//: Fill in //Source port// of forwarded port. Example: 3111. | ||
| Save the session and login. | Save the session and login. | ||
| - | ===== Setting up tunnel using PuTTY for FTP session ===== | + | ===== [[ftp_putty]] Setting up tunnel using PuTTY for FTP session ===== |
| ==== Setting up the tunnel ==== | ==== Setting up the tunnel ==== | ||
| - | In PuTTY configure a session for //Server A//. I.e. particularly fill in //Host Name//. Then switch to //Connection > SSH > Tunnels// tab. And add new forwarded port: | + | In PuTTY configure a session for //Server A//. I.e. particularly fill in //Host Name//. Then switch to //Connection > SSH > Tunnels// page. And add new forwarded port: |
| * //Source port//: Any free local port, typically above 3000. Example: 3111. | * //Source port//: Any free local port, typically above 3000. Example: 3111. | ||
| * //Destination//: Leave empty. | * //Destination//: Leave empty. | ||
| Line 48: | Line 63: | ||
| putty.exe <Server A> -D 3111 | putty.exe <Server A> -D 3111 | ||
| - | For more information see [[http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter3.html#using-port-forwarding|PuTTY documentation on port forwarding]]. | + | For more information see [[&url(puttydoc)/Chapter3.html#using-port-forwarding|PuTTY documentation on port forwarding]]. |
| ==== Connecting through the tunnel ==== | ==== Connecting through the tunnel ==== | ||
| - | In WinSCP configure an FTP session for //Server B//. Then go to //[[ui_login_proxy|Connection > Proxy]]// tab: | + | In WinSCP configure an FTP session for //Server B//. Then go to //[[ui_login_proxy|Proxy page]]// on Advanced Site Settings dialog: |
| - | * Set //Proxy type// to SOCKS5·(this will force [[ui_login_connection#passive_mode|passive mode]] if it was not set already). | + | * Set //Proxy type// to SOCKS5.((This will force [[ui_login_connection#connection|passive mode]], if it was not set already.)) |
| - | * //Proxy host name//: Fill in "localhost". | + | * //Proxy hostname//: Fill in "localhost". |
| * //Port number//: Fill in //Source port// of forwarded port. Example: 3111. | * //Port number//: Fill in //Source port// of forwarded port. Example: 3111. | ||
| Save the session and login. | Save the session and login. | ||