我是perl脚本新手,下面的代码是从sftp服务器下载文件。
#!/usr/bin/perl
use strict;
use warnings;
use Net::SFTP::Foreign;
my $sftp = Net::SFTP::Foreign->new(
'auser@sftp.rent.com',
password => 'auser123',
more => ['-v']
);
$sftp->get('outgoing/DATA.ZIP', '/h
在Unix上,您可以使用Expect和Empty等工具,使用伪终端与sftp等终端应用程序进行交互。我有一台安装了cygwin的Windows机器,我的C#应用程序需要启动sftp会话才能将一些文件传输到远程机器。
我从如下所示的代码开始
var p = new Process();
p.StartInfo = new ProcessStartInfo
{
FileName = "sftp",
UseShellExecute = false,
CreateNoWindow = false,
RedirectStandardInput = tru
我在我的食谱中有以下资源
remote_file '/tmp/test.txt' do
source 'sftp://root@xyz.imzcloud.local:22/tmp/test.txt'
end
在这里,我试图将远程主机上的文件放到chef-client上。chef-client无需密码即可通过ssh访问remote_host (使用ssh密钥)。当我运行这个食谱时,我得到了no password provided in the sftp URI。不提供密码如何通过sftp获取文件?
我已经创建了一个脚本,它将使用SFTP连接到服务器。为了避免将密码以纯文本形式放入脚本中,我计划将其放入以base64编码的文件中。我能从文件里读出来没问题。但我不知道如何用Expect解码base64。因此,目前,脚本读取文件并将密码(直接)放入脚本中。怎么破译?如果有这样的好方法,我准备将所有脚本移回Shell/bash。
谢谢。下面是代码:
#!/usr/bin/expect
set myPassword [open "sftp_auth.cfg" r]
set data [read $myPassword]
spawn sftp myUser@111.111.111.
这是我的脚本
#!/bin/ksh
RemoteFile=`grep "${File}" ${TempLog}` --> the value of the variable is Site Information_2013-07-04-00-01-26.CSV
/usr/bin/expect << EOF
spawn sftp user@server
expect "password:"
send "123fakepassword\n"
expect "sftp>"
send "cd /home/
目标:限制用户访问主目录和家庭中的符号链接目录。
我在sshd_config中尝试了以下配置
# Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp
Match user matt
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
然后重新启动sshd。用户不能使用正确的密码登录。连接拒绝身份验证失败。