sftp

Why does automating SFTP with Expect hang after sending the password?

痴心易碎 提交于 2019-12-23 02:52:53
问题 I am attempting to automate uploading some files from my Linux server to an FTP-enabled Windows server. I am successfully doing so manually using SFTP and then issuing the put command. However, when called from cron, my script keeps stopping for a password. Below is the code I am attempting to use: #!/usr/bin/expect #!/bin/sh clear spawn sftp remoteuser@43.123.0.10 expect "password" send "world" expect eof As it stands, it stops each time to request a password. Why doesn't send "world"

Selecting FTP protocol in WinSCP script

可紊 提交于 2019-12-23 02:39:05
问题 Before scheduling script it is worth to check how it works. so from Command Prompt I have just run my batch file. The server rejected SFTP connection, but it listens for FTP connections. Did you want to use FTP protocol instead of SFTP? Prefer using encryption. Image: As shown in the image above, I have specified that It is FTP file protocol. But It doesn't help. So far I have looked up: https://winscp.net/eng/docs/message_server_rejected_sftp_listens_for_ftp https://winscp.net/eng/docs/ui

List complete hierarchy of a directories at SFTP server using JSch in Java

折月煮酒 提交于 2019-12-23 00:52:26
问题 I want to display complete hierarchy of a directory at a remote location using JSch. The location has multiple folders and a folder may or may not have files. Code written by me (taken reference from SFTP Read all files in directory): sftpChannel.cd(remotePath); Vector<String> files = sftpChannel.ls("*"); List<String> ret=new ArrayList<>(); for (int i = 0; i < files.size(); i++) { Object obj = files.elementAt(i); if (obj instanceof com.jcraft.jsch.ChannelSftp.LsEntry) { LsEntry entry =

Get last 15 lines from a large file in SFTP with phpseclib [duplicate]

你说的曾经没有我的故事 提交于 2019-12-23 00:51:11
问题 This question already has answers here : How do you get last some lines of file via SFTP in PHP (3 answers) Closed 11 months ago . I want to get the last 15 lines from a large file (30MB) from a SFTP server using PHP. I tried using the phpseclib's SFTP functionality like that: include('./Net/SFTP.php'); $sftp = new Net_SFTP("server", 2022); if (!$sftp->login('username', 'password')) { exit("Login error"); } $size = $sftp->size('./file.txt'); $Container = nl2br($sftp->get('./file.txt', false,

Get last 15 lines from a large file in SFTP with phpseclib [duplicate]

天大地大妈咪最大 提交于 2019-12-23 00:51:08
问题 This question already has answers here : How do you get last some lines of file via SFTP in PHP (3 answers) Closed 11 months ago . I want to get the last 15 lines from a large file (30MB) from a SFTP server using PHP. I tried using the phpseclib's SFTP functionality like that: include('./Net/SFTP.php'); $sftp = new Net_SFTP("server", 2022); if (!$sftp->login('username', 'password')) { exit("Login error"); } $size = $sftp->size('./file.txt'); $Container = nl2br($sftp->get('./file.txt', false,

Connect to a linux system secured by RSA SecurID using ssh2 in Java

余生颓废 提交于 2019-12-22 17:49:01
问题 I want to create a connection from a Windows system to a Linux machine which uses RSA token Passcode for authentication and I want to run shell commands and get the output from the Java code. When logging into that Linux system using putty has the following steps: Enter IP and port and connect Enter username in the PuTTY terminal which asks "login as: " Enter PASSCODE where we enter RSA SecurID I have already tried connecting using Jsch package and it doesn't connect. I also tried a jcabi-ssh

Java SFTP client that takes private key as a string

蹲街弑〆低调 提交于 2019-12-22 17:41:05
问题 Apache Commons and JSch both require a private key file to set up an SFTP connection. The project I'm working on will be used to connect to multiple SFTP servers. Therefore, we do not hope to deploy multiple private key files, but rather keep these keys as strings in an encrypted config file. Is there an SFTP library that doesn't require a file object for private key? 回答1: The JSch has an addIdentity method overload that takes the key from a buffer: public class JSch { ... public void

Getting session and SFTP channel in Java using JSch library

萝らか妹 提交于 2019-12-22 14:00:28
问题 I am using JSch library for SFTP. I need to do several operations on SFTP server like move remote files in other directory, pull files, etc. For all these operations I need Session and from it I get Channel an then cast it to ChannelSftp . This is redundant step. So I thought of abstracting it into a private method. private ChannelSftp getChannelSftp() throws JSchException { java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); JSch jsch = new

How to get the files of remote directory using a pattern with C# and WinSCP

不羁岁月 提交于 2019-12-22 12:36:13
问题 I'm trying to get an specific files from a remote server with FTP/SFTP connection, the issue that I'm having is, I'm trying to get the count of files in the remote directory with an specific pattern. I'm using a mask but is not working for me, it throwing an exception: this is what I have DataFile.sRemoteDirectory = "/user/ftpuser/test/"; receivepattern = "Del*"; filesCount = session.ListDirectory( session.EscapeFileMask(DataFile.sRemoteDirectory + receivepattern)) .Files.Where(x => !x

Modified date time changes when moving a file from Windows to UNIX server using SSH.NET

ぃ、小莉子 提交于 2019-12-22 12:20:34
问题 I am using SSH.NET in my C# application to copy files from a Windows to a UNIX server, I have a few scenarios for this: In the UNIX server directory if the file to be copied does not exist , then the modified datetime of the file when it is copied to the UNIX server changes to the copied datetime ? Is this correct because the modified datetime is not supposed to change right? In the UNIX Server directory if the file to be copied already exists , then on copying the same file which gets