3

I'm trying to connect to an SFTP server for which I have passwordless authentication setup. I can connect to this server from the terminal. However, when I try to access the server using Springboot - Camel-SFTP, I get an exception:

2018-08-29 14:59:24,617 WARN org.apache.camel.component.file.remote.SftpConsumer : Error auto creating directory: incoming due Cannot connect to sftp://username@host.net:22. This exception is ignored. org.apache.camel.component.file.GenericFileOperationFailedException: Cannot connect to sftp://username@host.net:22

Caused by: com.jcraft.jsch.JSchException: Auth fail at com.jcraft.jsch.Session.connect(Session.java:519) at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:116) ... 33 common frames omitted

This is the endpoint for my route: file-endpoint: sftp://username@host.net/incoming?streamDownload=true&noop=true&disconnect=true&stepwise=false&useList=false&fileName=abc.txt&ignoreFileNotFoundOrPermissionError=false&sendEmptyMessageWhenIdle=true&privateKeyPassphrase=XXX&preferredAuthentications=publickey&privateKeyFile=/Users/username/.ssh/id_rsa&scheduler=spring&scheduler.cron=0+0/1++++

Any help would be appreciated. Thanks!

Mounika
  • 31
  • 1
  • 5

2 Answers2

2

From the filename, I'd assume an RSA key -- be sure that this is the case. I've had problems with JSch using an ed25519 key.

Additionally, in the SFPT route's that I've set up, I don't use "user@" in the URI; I just have

 sftp://some.host/directory?username=someone?privateKeyFile=<>[..options..]

but I don't include a blank password attribute as indicated by fliot

Finally, you might try to check the destination server's sshd log; it may have something useful.

CrankyElderGod
  • 403
  • 4
  • 10
  • Can follow this answer : https://stackoverflow.com/questions/62216136/apache-camel-set-privatekey-sftp/73292347#73292347 – Ramgau Aug 09 '22 at 13:12
0

Simple answer : Add username and password, even if password may be empty.


Long answer: I got several working routes with username=something&password=&privateKeyPassphrase=XXX&preferredAuthentications=publickey&privateKeyFile=id_rsa

By the way, the path of your private key, make me anxious, by default, on linux, a local user is allowed to use local file as private ssh key, only the key is "chmod 400", or similar. Please, check your Karaf or Servicemix instance can correctly read this path.

Additionnaly, you can see the entire sFTP workout, with

log4j.logger.org.apache.camel.component.file.remote.SftpOperations = ON
fliot
  • 1
  • 2