SFTP through firewall fails to use proxy

조회 수: 8 (최근 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 CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by