フィルターのクリア

SFTP through firewall fails to use proxy

29 ビュー (過去 30 日間)
Jeff Mandel
Jeff Mandel 2024 年 2 月 15 日
回答済み: Siraj 2024 年 2 月 19 日
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.

回答 (1 件)

Siraj
Siraj 2024 年 2 月 19 日
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.

カテゴリ

Help Center および File ExchangeFTP File Operations についてさらに検索

タグ

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by