我需要编写一个程序来将一些文件发送到"sftp"服务器.我用Google搜索,但发现有类似的东西叫做"ftp over SSL".
它们是一样的吗?
我想在Inno Setup编译过程开始时调用批处理文件.即在开始编译之前,执行外部操作.这是可能的还是我的外部活动应该包装Inno Setup编译过程?
我的目标是连接到防火墙后面的服务器(主机).我可以通过连接到网络中的另一个服务器(隧道)然后SSH到此服务器来访问此服务器.但是我无法通过JSch实现相同的场景.
我无法使用以下代码工作,我为此目的编写了这些代码.如果我在这里做任何蠢事,请告诉我.
public class JschExecutor {
public static void main(String[] args){
JschExecutor t=new JschExecutor();
try{
t.go();
} catch(Exception ex){
ex.printStackTrace();
}
}
public void go() throws Exception{
StringBuilder outputBuffer = new StringBuilder();
String host="xxx.xxx.xxx.xxx"; // The host to be connected finally
String user="user";
String password="passwrd";
int port=22;
String tunnelRemoteHost="xx.xx.xx.xx"; // The host from where the tunnel is created
JSch jsch=new JSch();
Session session=jsch.getSession(user, host, port);
session.setPassword(password);
localUserInfo lui=new localUserInfo();
session.setUserInfo(lui);
session.setConfig("StrictHostKeyChecking", "no");
ProxySOCKS5 proxyTunnel = new ProxySOCKS5(tunnelRemoteHost, 22);
proxyTunnel.setUserPasswd(user, password); …Run Code Online (Sandbox Code Playgroud) 我需要使用C#代码执行此操作:
所以我试着这样做:
ProcessStartInfo proc = new ProcessStartInfo()
{
FileName = @"C:\putty.exe",
UseShellExecute = true, //I think I need to use shell execute ?
RedirectStandardInput = false,
RedirectStandardOutput = false,
Arguments = string.Format("-ssh {0}@{1} 22 -pw {2}", userName, hostIP, password)
... //How do I send commands to be executed here ?
};
Process.Start(proc);
Run Code Online (Sandbox Code Playgroud) 我是Inno Setup的新手,我希望在Inno Setup中为我的可执行文件添加一个桌面图标.该文件存储在
C:\Users\PycharmProjects\GIOTTOconverter\dist\giotto.ico
Run Code Online (Sandbox Code Playgroud)
我尝试了几个例子,但没有结果.
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "GIOTTO"
#define MyAppVersion "1.0"
#define MyAppExeName "GIOTTO.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{48A8A469-1711-46FD-AC87-1596EF57C123}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName} …Run Code Online (Sandbox Code Playgroud) 我有这种情况:
本地主机--------- jump-host ------- target-machine
我正在尝试使用Paramiko在Python中编写代码,首先从本地主机SSH跳转到主机,然后从跳转主机SSH到目标机器.从目标机器,我想捕获一些输出并将它们作为变量或文件存储在本地(尚未到达那一点).我在Stack Overflow中找到了一个例子,他们谈到了使用嵌套式SSH与Paramiko,我遵循它但是我被困在这里:
我的代码:
enter code here
#!/usr/bin/python
#
# Paramiko
#
import paramiko
import sys
import subprocess
#
# we instantiate a new object referencing paramiko's SSHClient class
#
vm=paramiko.SSHClient()
vm.set_missing_host_key_policy(paramiko.AutoAddPolicy())
vm.connect('192.168.115.103',username='osmanl',password='xxxxxx')
#
vmtransport = vm.get_transport()
dest_addr = ('192.168.115.103', 22)
local_addr = ('127.0.0.1', 22)
vmchannel = vmtransport.open_channel("direct-tcpip", dest_addr, local_addr)
#
jhost=paramiko.SSHClient()
jhost.set_missing_host_key_policy(paramiko.AutoAddPolicy())
jhost.load_host_keys('/home/osmanl/.ssh/known_hosts')
jhost.connect('10.103.53.26', username='latiu', password='xxxx', sock=vmchannel)
#
stdin, stdout, stderr = rtr.exec_command("show version | no-more")
#
print stdout.readline()
#
jhost.close()
vm.close()
# End
Run Code Online (Sandbox Code Playgroud)
当我运行上面的操作时,我收到此错误: …
我们可以写一个get这样的简单:
import pysftp
hostname = "somehost"
user = "bob"
password = "123456"
filename = 'somefile.txt'
with pysftp.Connection(hostname, username=user, private_key='/home/private_key_file') as sftp:
sftp.get(filename)
Run Code Online (Sandbox Code Playgroud)
但是,我想在文件名中指定一个模式,例如: '*.txt'
关于如何使用这个的任何想法pysftp?
我正在使用.iss脚本在Inno Setup Compiler中构建一个exe文件.我需要将一些node_modules打包到这个应用程序中,所以我有一行看起来像这样:[Files]
Source: "{#SourcePath}Encore.Warehouse.UI\bin\Warehouse_Release\warehouse\*"; \
DestDir: "{app}\warehouse"; Flags: ignoreversion recursesubdirs createallsubdirs
Run Code Online (Sandbox Code Playgroud)
编译时,我收到此错误:
这是编译器输出:
所以,它似乎运行正常,直到它中止.我最初的想法是,browser.js它不存在,但经过双重检查,情况并非如此.此外,我在源路径中使用通配符,因此编译器知道该文件存在,但似乎在压缩它时遇到问题.
另一个可能导致问题的是文件路径长度.由于嵌套依赖性,节点模块通常最终会出现荒谬的文件路径长度.在这种情况下,路径长度为260.假设这是造成问题的原因,有什么方法可以绕过它吗?
这段代码可以帮我建立一个shh连接.我知道set_missing_host_key_policy在没有找到密钥时会有所帮助known_hosts.但它的行为并不像实际的那样ssh,因为在我第一次运行这段代码之后,我认为它host_key会被添加到known_hosts并且我不再需要该函数set_missing_host_key_policy()了.但是,我错了(paramiko.ssh_exception.SSHException).我怎样才能永久添加host_key到known_hosts使用paramiko?(由于后端代码的某一部分是用'C'编写的,因此需要host_key找到它known_hosts)
还是我误解了什么?我需要一些指导......
import paramiko
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=str(host),username =str(user),password=str(pswd))
Run Code Online (Sandbox Code Playgroud) 所以我在通过 SFTP 连接到远程服务器时遇到了很多问题。我已经尝试过像下面这样的正常方法。
sftp = pysftp.Connection(host='Host',username='username',password='passwd',private_key=".ppk")
Run Code Online (Sandbox Code Playgroud)
哪个不起作用。我收到以下错误:
SSHException: 找不到主机 ***** 的主机密钥。
然后我尝试了以下方法:
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
s = pysftp.Connection(host='host', username='user', password='password', cnopts=cnopts)
Run Code Online (Sandbox Code Playgroud)
这也不起作用。我收到以下错误:
BadAuthenticationType: ('Bad authentication type', ['publickey']) (allowed_types=['publickey'])
同样,当我运行以下命令时:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect("host",username = "username",password = "password")
ssh_session = client.get_transport().open_session()
Run Code Online (Sandbox Code Playgroud)
我犯了同样的错误:
BadAuthenticationType: ('Bad authentication type', ['publickey']) (allowed_types=['publickey'])
python ×4
ssh ×4
inno-setup ×3
sftp ×3
paramiko ×2
pysftp ×2
.net ×1
c# ×1
compilation ×1
desktop ×1
executable ×1
filepath ×1
ftp ×1
ftps ×1
icons ×1
installation ×1
java ×1
jsch ×1
max-path ×1
nested ×1
node-modules ×1
ssh-tunnel ×1
ssh.net ×1
ssl ×1