Details
Description
I set up a sshd-server als follows:
this.sshd = SshServer.setUpDefaultServer(); this.sshd.setPort(2023); this.sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("keys")); List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>(); userAuthFactories.add(new UserAuthNone.Factory()); this.sshd.setUserAuthFactories(userAuthFactories); this.sshd.setCommandFactory(new ScpCommandFactory()); List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>(); namedFactoryList.add(new SftpSubsystem.Factory()); this.sshd.setSubsystemFactories(namedFactoryList);
After starting the server, I upload a file (scp -P 2023 filename.txt localhost: ) containing:
1234567890
Hexdump (hexdump -C file.txt) of the file is
00000000 31 32 33 34 35 36 37 38 39 30 0a 0a |1234567890..|
0000000c
Afterwards I remove "234567890" from the local file an upload it again. Instead of containing on "1\n" the file contains:
1
4567890
Hexdump (hexdump -C file.txt) of the file is
00000000 31 0a 0a 34 35 36 37 38 39 30 0a 0a |1..4567890..|
0000000c
It seems that "23" is replaced by two newlines and the rest of the original (on the server) remains in the file and is not overwritten.