我在我的Visual Studio Code工作流中使用vscode-sftp扩展将文件上传到远程服务器,每当我保存时。我正在尝试实现无密码身份验证,就像我以前使用Sublime Text的SFTP插件一样。但是,问题在于对于vscode-sftp,在sftp.json
文件中,我必须以纯文本形式输入我的密码才能使其工作:
{
"host": "mysamplehost.com",
"port": 22,
"username": "username",
"password": "password",
"protocol": "sftp",
"agent": null,
"privateKeyPath": null,
"passphrase": null,
"passive": false,
"interactiveAuth": false,
"remotePath": "/",
"uploadOnSave": true,
...
}
然而,如果我通过SSH登录我的服务器,我不需要输入密码-因为我在MacBook中有SSH密钥。如何配置vscode-sftp以使用此身份验证方法?我在文档中看到以下评论,但我不知道如何设置:
/**
* string - Path to ssh-agent's UNIX socket for ssh-agent-based user authentication.
* Windows users: set to 'pageant' for authenticating with Pageant or (actual) path to a cygwin "UNIX socket.
*/
agent: null,
privateKeyPath: null, // absolute path to user private key
passphrase: null,
passive: false, // ftp passive mode