Private key password for sftp object?

조회 수: 7 (최근 30일)
Garrett Good
Garrett Good 2022년 9월 8일
편집: Garrett Good 2024년 9월 1일
Hello, Matlab2021 has an sftp object like the old ftp object. That can be used with either password authentication or a public and private key (see help sftp).
Our private key however has a password. The matlab "connection" object can handle this, but there doesn't seem to be a way to pass this to the sftp object and my connection is rejected...
Anyone know how to do this?
(We were previously using the ssh2 toolbox from the fileexchange but this has some problems for us).
Thanks in advance.

답변 (1개)

Vidip Jain
Vidip Jain 2023년 9월 27일
I understand you want to use a private key with a password for SFTP authentication in MATLAB 2021, you can use the following steps to do the same:
  1. Create a ‘connection’ object to the SFTP server.
  2. Set the ‘PrivateKeyFile’ and ‘PrivateKeyPassword’ properties of the connection object.
  3. Create a ‘sftp’ object using the ‘connection’ object.
The ‘connection’ object can be used to manage the SSH connection to the SFTP server. The ‘connection’ object can also be used to specify the private key file and password.
For further information, refer to the documentation links below:
  댓글 수: 3
Walter Roberson
Walter Roberson 2024년 8월 31일
Why not use the syntax
s = sftp(host,user,"PublicKeyFile",publickeyfile,"PrivateKeyFile",privatekeyfile) %uses the key files at the specified locations.
Garrett Good
Garrett Good 2024년 9월 1일
편집: Garrett Good 2024년 9월 1일
Thank you for your response, Walter.
My ssh understanding is limited but it seems there are more than the 2 possiblities supported by Matlab.
  1. username+password
  2. public + private key pair.
We do not have a keypair, but rather a private key from a client with a passphrase. We can connect via sftp in a terminal with just the private key and this works. We can also decrypt the key and avoid the password query. Matlab's sftp will only accept a private key as part of a pair and generating a public key from this private one also has not worked (connection is refused).
We used to use this https://www.mathworks.com/matlabcentral/fileexchange/35409-ssh-sftp-scp-for-matlab-v2, which can connect, but now it doesn't like our drivers, and was always quite difficult as compared to a matlab ftp object, in particular, as it's missing a "dir" command.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by