How to improve or remove sftp hard code password camel code












0















I have the following code:-



    public class FtpRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
try{
from("file:c:/temp/input/")
.streamCaching()
.to("sftp://sftpuser@192.168.10.54:/sftpuser/?password=dev&passiveMode=true");
}catch (Exception ex){
System.out.printf("ex: "+ex.getMessage());
}
}
}


There I have sftp password "dev" in the code. That is ugly. How can I remove it and set it in a better way?










share|improve this question

























  • Have you looked at using SSH public/private keys? The camel sftp component has a number of options to allow it.

    – pcoates
    Nov 24 '18 at 20:53











  • No, I didn't. But I don't know how to do it. Can you pls suggest how?

    – masiboo
    Nov 24 '18 at 20:55
















0















I have the following code:-



    public class FtpRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
try{
from("file:c:/temp/input/")
.streamCaching()
.to("sftp://sftpuser@192.168.10.54:/sftpuser/?password=dev&passiveMode=true");
}catch (Exception ex){
System.out.printf("ex: "+ex.getMessage());
}
}
}


There I have sftp password "dev" in the code. That is ugly. How can I remove it and set it in a better way?










share|improve this question

























  • Have you looked at using SSH public/private keys? The camel sftp component has a number of options to allow it.

    – pcoates
    Nov 24 '18 at 20:53











  • No, I didn't. But I don't know how to do it. Can you pls suggest how?

    – masiboo
    Nov 24 '18 at 20:55














0












0








0








I have the following code:-



    public class FtpRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
try{
from("file:c:/temp/input/")
.streamCaching()
.to("sftp://sftpuser@192.168.10.54:/sftpuser/?password=dev&passiveMode=true");
}catch (Exception ex){
System.out.printf("ex: "+ex.getMessage());
}
}
}


There I have sftp password "dev" in the code. That is ugly. How can I remove it and set it in a better way?










share|improve this question
















I have the following code:-



    public class FtpRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
try{
from("file:c:/temp/input/")
.streamCaching()
.to("sftp://sftpuser@192.168.10.54:/sftpuser/?password=dev&passiveMode=true");
}catch (Exception ex){
System.out.printf("ex: "+ex.getMessage());
}
}
}


There I have sftp password "dev" in the code. That is ugly. How can I remove it and set it in a better way?







passwords apache-camel sftp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 19:48







masiboo

















asked Nov 24 '18 at 19:19









masiboomasiboo

1,32532556




1,32532556













  • Have you looked at using SSH public/private keys? The camel sftp component has a number of options to allow it.

    – pcoates
    Nov 24 '18 at 20:53











  • No, I didn't. But I don't know how to do it. Can you pls suggest how?

    – masiboo
    Nov 24 '18 at 20:55



















  • Have you looked at using SSH public/private keys? The camel sftp component has a number of options to allow it.

    – pcoates
    Nov 24 '18 at 20:53











  • No, I didn't. But I don't know how to do it. Can you pls suggest how?

    – masiboo
    Nov 24 '18 at 20:55

















Have you looked at using SSH public/private keys? The camel sftp component has a number of options to allow it.

– pcoates
Nov 24 '18 at 20:53





Have you looked at using SSH public/private keys? The camel sftp component has a number of options to allow it.

– pcoates
Nov 24 '18 at 20:53













No, I didn't. But I don't know how to do it. Can you pls suggest how?

– masiboo
Nov 24 '18 at 20:55





No, I didn't. But I don't know how to do it. Can you pls suggest how?

– masiboo
Nov 24 '18 at 20:55












1 Answer
1






active

oldest

votes


















0















  1. Have a look at you sftp server's documentation for how to setup access using SSH keys. You'll need to generate a key pair if you don't already have one (e.g. with ssh-keygen) then put the public key on the sftp server. Don't use a pass phrase. If you do you'll have to add that to the camel route, so it'll look just as ugly.


  2. Check you can do a transfer with an ftp client using your private key. i.e. test the keys before trying to use them with camel.



  3. Change your route to use the private key



    from("file:c:/temp/input/")
    .streamCaching()
    .to("sftp://sftpuser@192.168.10.54:/sftpuser/?privateKeyFile=path-to-private-key-file&passiveMode=true");







share|improve this answer
























  • Thanks for the answer. I don't have much knowledge of ssh public/private key. I generated new key those are located in .ssh/id_rsa and .ssh/id_rsa.pub. I am confused exactly where to put the public key in the sftp server. In the sftp server is mint linux. There are several users. Should I put it in the sftp user location as it is /home/sftpuser/.ssh/? There is already a id_rsa.pub. Should I replace it?

    – masiboo
    Nov 25 '18 at 9:43











  • I'm not familiar with the sftp server in mint linux. As I said, you'll need to refer to the documentation to work this bit out. There are sure to be guides online too if you do a bit of searching.

    – pcoates
    Nov 25 '18 at 10:27











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53461586%2fhow-to-improve-or-remove-sftp-hard-code-password-camel-code%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0















  1. Have a look at you sftp server's documentation for how to setup access using SSH keys. You'll need to generate a key pair if you don't already have one (e.g. with ssh-keygen) then put the public key on the sftp server. Don't use a pass phrase. If you do you'll have to add that to the camel route, so it'll look just as ugly.


  2. Check you can do a transfer with an ftp client using your private key. i.e. test the keys before trying to use them with camel.



  3. Change your route to use the private key



    from("file:c:/temp/input/")
    .streamCaching()
    .to("sftp://sftpuser@192.168.10.54:/sftpuser/?privateKeyFile=path-to-private-key-file&passiveMode=true");







share|improve this answer
























  • Thanks for the answer. I don't have much knowledge of ssh public/private key. I generated new key those are located in .ssh/id_rsa and .ssh/id_rsa.pub. I am confused exactly where to put the public key in the sftp server. In the sftp server is mint linux. There are several users. Should I put it in the sftp user location as it is /home/sftpuser/.ssh/? There is already a id_rsa.pub. Should I replace it?

    – masiboo
    Nov 25 '18 at 9:43











  • I'm not familiar with the sftp server in mint linux. As I said, you'll need to refer to the documentation to work this bit out. There are sure to be guides online too if you do a bit of searching.

    – pcoates
    Nov 25 '18 at 10:27
















0















  1. Have a look at you sftp server's documentation for how to setup access using SSH keys. You'll need to generate a key pair if you don't already have one (e.g. with ssh-keygen) then put the public key on the sftp server. Don't use a pass phrase. If you do you'll have to add that to the camel route, so it'll look just as ugly.


  2. Check you can do a transfer with an ftp client using your private key. i.e. test the keys before trying to use them with camel.



  3. Change your route to use the private key



    from("file:c:/temp/input/")
    .streamCaching()
    .to("sftp://sftpuser@192.168.10.54:/sftpuser/?privateKeyFile=path-to-private-key-file&passiveMode=true");







share|improve this answer
























  • Thanks for the answer. I don't have much knowledge of ssh public/private key. I generated new key those are located in .ssh/id_rsa and .ssh/id_rsa.pub. I am confused exactly where to put the public key in the sftp server. In the sftp server is mint linux. There are several users. Should I put it in the sftp user location as it is /home/sftpuser/.ssh/? There is already a id_rsa.pub. Should I replace it?

    – masiboo
    Nov 25 '18 at 9:43











  • I'm not familiar with the sftp server in mint linux. As I said, you'll need to refer to the documentation to work this bit out. There are sure to be guides online too if you do a bit of searching.

    – pcoates
    Nov 25 '18 at 10:27














0












0








0








  1. Have a look at you sftp server's documentation for how to setup access using SSH keys. You'll need to generate a key pair if you don't already have one (e.g. with ssh-keygen) then put the public key on the sftp server. Don't use a pass phrase. If you do you'll have to add that to the camel route, so it'll look just as ugly.


  2. Check you can do a transfer with an ftp client using your private key. i.e. test the keys before trying to use them with camel.



  3. Change your route to use the private key



    from("file:c:/temp/input/")
    .streamCaching()
    .to("sftp://sftpuser@192.168.10.54:/sftpuser/?privateKeyFile=path-to-private-key-file&passiveMode=true");







share|improve this answer














  1. Have a look at you sftp server's documentation for how to setup access using SSH keys. You'll need to generate a key pair if you don't already have one (e.g. with ssh-keygen) then put the public key on the sftp server. Don't use a pass phrase. If you do you'll have to add that to the camel route, so it'll look just as ugly.


  2. Check you can do a transfer with an ftp client using your private key. i.e. test the keys before trying to use them with camel.



  3. Change your route to use the private key



    from("file:c:/temp/input/")
    .streamCaching()
    .to("sftp://sftpuser@192.168.10.54:/sftpuser/?privateKeyFile=path-to-private-key-file&passiveMode=true");








share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 21:44









pcoatespcoates

941128




941128













  • Thanks for the answer. I don't have much knowledge of ssh public/private key. I generated new key those are located in .ssh/id_rsa and .ssh/id_rsa.pub. I am confused exactly where to put the public key in the sftp server. In the sftp server is mint linux. There are several users. Should I put it in the sftp user location as it is /home/sftpuser/.ssh/? There is already a id_rsa.pub. Should I replace it?

    – masiboo
    Nov 25 '18 at 9:43











  • I'm not familiar with the sftp server in mint linux. As I said, you'll need to refer to the documentation to work this bit out. There are sure to be guides online too if you do a bit of searching.

    – pcoates
    Nov 25 '18 at 10:27



















  • Thanks for the answer. I don't have much knowledge of ssh public/private key. I generated new key those are located in .ssh/id_rsa and .ssh/id_rsa.pub. I am confused exactly where to put the public key in the sftp server. In the sftp server is mint linux. There are several users. Should I put it in the sftp user location as it is /home/sftpuser/.ssh/? There is already a id_rsa.pub. Should I replace it?

    – masiboo
    Nov 25 '18 at 9:43











  • I'm not familiar with the sftp server in mint linux. As I said, you'll need to refer to the documentation to work this bit out. There are sure to be guides online too if you do a bit of searching.

    – pcoates
    Nov 25 '18 at 10:27

















Thanks for the answer. I don't have much knowledge of ssh public/private key. I generated new key those are located in .ssh/id_rsa and .ssh/id_rsa.pub. I am confused exactly where to put the public key in the sftp server. In the sftp server is mint linux. There are several users. Should I put it in the sftp user location as it is /home/sftpuser/.ssh/? There is already a id_rsa.pub. Should I replace it?

– masiboo
Nov 25 '18 at 9:43





Thanks for the answer. I don't have much knowledge of ssh public/private key. I generated new key those are located in .ssh/id_rsa and .ssh/id_rsa.pub. I am confused exactly where to put the public key in the sftp server. In the sftp server is mint linux. There are several users. Should I put it in the sftp user location as it is /home/sftpuser/.ssh/? There is already a id_rsa.pub. Should I replace it?

– masiboo
Nov 25 '18 at 9:43













I'm not familiar with the sftp server in mint linux. As I said, you'll need to refer to the documentation to work this bit out. There are sure to be guides online too if you do a bit of searching.

– pcoates
Nov 25 '18 at 10:27





I'm not familiar with the sftp server in mint linux. As I said, you'll need to refer to the documentation to work this bit out. There are sure to be guides online too if you do a bit of searching.

– pcoates
Nov 25 '18 at 10:27


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53461586%2fhow-to-improve-or-remove-sftp-hard-code-password-camel-code%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Lallio

Unable to find Lightning Node

Futebolista