Skip to content
Browse files

Use a constant default target file name for seed SCP upload method

To make seed upload (in /Settings_p.html?page=seed page) with SCP easier
when the user specify a remote target directory path.

See report by @vikulin in issue #227
  • Loading branch information...
luccioman committed Sep 16, 2018
1 parent 51f4be1 commit 2a73b63d9e1a286cf138ac50e57577ffac1107bc
Showing with 26 additions and 10 deletions.
  1. +26 −10 source/net/yacy/peers/operation/
@@ -80,7 +80,7 @@ else if (seedScpServerPort == null || seedScpServerPort.isEmpty())
throw new Exception("Seed SCP upload settings not configured properly. Server port is not a vaild integer.");

return sshc.put(seedScpServer, port, seedFile, seedScpPath, seedScpAccount, seedScpPassword);
return sshc.put(seedScpServer, port, seedFile, seedScpPath, "seed.txt", seedScpAccount, seedScpPassword);
} catch (final Exception e) {
throw e;
@@ -93,12 +93,34 @@ else if (seedScpServerPort == null || seedScpServerPort.isEmpty())


* Utility class to copy local files to a remote SSH server.
* @see <a href="">JCraft scp to remote file example</a>
class sshc {

* Copy a local file to a remote SSH server
* @param host the target SSH server host (domain name or IP
* address)
* @param port the target SSH server port
* @param localFile the local file to copy
* @param remotePath the file path on the remote SSH server target
* @param defaultTargetFileName the default file name to use when the remotePath
* is an existing directory path. Ignored when
* remotePath is file path.
* @param account the user name to use for the SSH connection
* @param password the password to use for the SSH connection
* @return a message confirming the success of the operation
* @throws Exception when an unexpected error occurred.
public static String put(
final String host,
final int port,
final File localFile,
final String remoteName,
final String remotePath,
final String defaultTargetFileName,
final String account,
final String password
) throws Exception {
@@ -130,7 +152,7 @@ public static String put(
// trying to connect ...

String command="scp -p -t " + remoteName;
String command="scp -p -t " + remotePath;
final Channel channel = session.openChannel("exec");

@@ -144,13 +166,7 @@ public static String put(

// send "C0644 filesize filename", where filename should not include '/'
final int filesize=(int)(localFile).length();
command="C0644 "+filesize+" ";
command="C0644 " + filesize + " " + defaultTargetFileName;
out.write(UTF8.getBytes(command)); out.flush();

0 comments on commit 2a73b63

Please sign in to comment.
You can’t perform that action at this time.