有没有办法通过使用-load profile文件通过pscp发送文件,而不指定主机,如果我已经在configuration文件中指定它?
我只想指定源path,目标path和configuration文件,而不指定用户和主机,因为它已经在configuration文件中。
例如:我想要批量创build脚本,将发送到主机的根目录作为在第二个参数给出的第一个参数文件给出的configuration文件:
@echo off pscp.exe -load %* SOMETHING:/ pause
但我不知道要放什么东西而不是SOMETHING 。 我需要该脚本来创build发送到Windows 8.1中的菜单条目(在发送到菜单的窗口快捷方式不能采取%1,%2,%*等,所以我必须创build脚本来重新安排参数在pscp中的顺序。
如果我理解正确:
您正在使用Windows主机,本地连接为“winuser”帐户;
在这样的主机上,你可以成功地使用“putty”来SSH远程主机(我们称之为“remote_host”)作为远程“root”用户进行身份validation。 假设您的身份validation是“基于密码的”;
你有一个“remote_host”的puttyconfiguration文件,不仅包括远程主机名/ ip_address,还包括“root”远程用户名;
您需要一个BAT文件,通过该文件,您可以从本地计算机“/从”远程主机“/从”远程主机“pscp”,而不必在此类BAT文件中明确报告“root”用户名。 这,因为在腻子configuration文件中,你已经指定了它。
这是正确的吗?
如果是的话,这样一个BAT文件:
@echo off pscp c:/tce-test.tce imac:/tmp pause
将本地窗口c:\ tcp-test.tce文件复制到putty“imac”configuration文件中指定的远程主机,并使用在同一个“imac”puttyconfiguration文件中指定的用户名连接到此主机,然后将文件写入远程/ tmp文件夹。
换句话说,正如在pscp文档中明确指出的那样
5.2.1.2 host The name of the remote server, or the name of an existing PuTTY saved session. In the latter case, the session's settings for hostname, port number, cipher type and username will be used.
您可以使用(代替主机参数)保存的腻子会话的名称。 正是你所需要的。
说了以上所有,让我join以下考虑:
用这样的方法,你正在执行一个固定的远程用户 :在腻子configuration文件中指定的用户 。 这是你可能不喜欢的约束;
通过在puttyconfiguration文件中不指定用户名,pscp将使用你在本地windows主机(以上例子中的“winuser”)中使用的用户名回退:如果本地用户名在SSH服务器上定义了类似的用户名,这可能是一个加号;
避免inputSSH密码的安全和舒适的方法是依靠SSH密钥authentication。 使用Windows,您可以find可在Windows启动时启动的Pageant代理程序,并控制(本地)用户身份validation密钥。 一旦代理运行并控制密钥,所有的putty-family-software(putty,pscp等)以及许多其他软件都可能正确地进行ssh-authenticate,而不会提示用户input任何密码不要认为这是安全弱点,因为它恰恰相反:使用密钥,可以加强authentication模式);
如果您依靠密钥进行身份validation,则可以使用“-i”选项将PSCP指向正确的密钥文件
来自: 官方PuTTY文档 :
3.8.3.18 -i: specify an SSH private key The -i option allows you to specify the name of a private key file in *.PPK format which PuTTY will use to authenticate with the server. This option is only meaningful if you are using SSH. For general information on public-key authentication, see chapter 8. This option is equivalent to the 'Private key file for authentication' box in the Auth panel of the PuTTY configuration box (see section 4.20.7).