SFTP through firewall fails to use proxy
8 views (last 30 days)
Show older comments
I work in a building that has an overly-restrictive firewall. On my Mac, I have ~/.ssh/config, I handle this with:
Host proxy.example.com
HostName proxy.example.com
ProxyCommand /opt/local/bin/proxytunnel -E -p www.example.com:443 -d 127.0.0.1:22
If I sftp from the command line, I see if correctly reads the config file and connects through proxytunnel. Matlab's sftp seems to ignore ~/.ssh/config. Digging deeper, I see sftp purports to support an HTTP proxy. In my Apache site for proxy.example.com, I have:
AllowConnect 22
This works fine as a SOCKS proxy (Apple Mail, for instance), but does not work either setting proxy.example.com:443 in MATLAB Web Preferences or in Mac Network proxy settings, or using the SOCKS proxy locally (127.0.0.1:1080). I'd prefer not to resort to a Java solution unless this can't be done with pure MATLAB.
0 Comments
Answers (1)
Siraj
on 19 Feb 2024
Hi!
It is my understanding that you’re trying to use "sftp" with proxy server settings to connect to a server and access its files but are running into some trouble. You've mentioned that you can connect to the server using sftp from the command line without any issues, yet when you try to use MATLAB's "sftp" function, you encounter problems.
The SFTP object created by the “sftp” function does not support proxy server settings, which is why it seems like your config file is being ignored. You can verify this limitation by checking the documentation provided by MathWorks at the following link:
As an alternative, you can try connecting to the server using SSH keys. In the "sftp" function, you can specify the paths to your public and private key files with the "PublicKeyFile" and "PrivateKeyFile" arguments. This method could provide a way for authentication. The default location of these key files is dependent on your operating system. Here's how you might use these arguments in your code:
s = sftp("sftp.example.net", "jsmith", "PublicKeyFile","/Users/abc/sshKeys/keys.pub", "PrivateKeyFile","/Users/abc/sshKeys/keys");
You can find more information in the MATLAB "sftp" function documentation:
Hope this helps.
0 Comments
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!