我想在powershell中使用sftp将文件从本地机器传输到远程服务器。
我使用了多种方式,如Open SFTPServer、Copy File、SFTPFileUploads、Session.put等,但都不起作用。
有人能帮我吗?
我试过的一个例子如下:
$sftp = Open-SFTPServer -serverAddress $sftpHost -userName $userName -userPassword $userPassword
Windows 10内置OpenSSH,但已禁用。其中包含sftp
、ssh
和scp
:等工具
# You may or may not need to restart after enabling the client
Add-WindowsCapability -Online -Name OpenSSH.Client
一旦启用,只需像往常一样连接
# this example is interactive, and starting from powershell
PS C:> sftp MyUser@MyServer
sftp> put test.txt
Uploading test.txt to /home/MyUser/test.txt
test.txt 100% 380 11.9KB/s 00:00
sftp> ls
test.txt
sftp> rm test.csv
Removing /home/MyUser/test.txt
sftp> quit
PS C:> # now back in powershell