• Post Reply Bookmark Topic Watch Topic
  • New Topic

SCP command  RSS feed

 
Sajan Patel
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
below is my code for copy one file from one server to another.

Runtime load = Runtime.getRuntime();
String sFileName = /bin/sh -c scp 20041229143332464.csv [UserName]@[192.0.0.1]:/FolderName1/FolderName2/FolderName3
Process process = load.exec(sFileName);

Problemm is It ask for password and I dont know how to pass password after initiating exec command.
Thanks in Advance
Solution Idea
1) For Unix Forum
Do we have any other option then SCP but secure with authentication in which we can pass password with itself (like PSCP does)
2) For JAVA Forum
Can we pass any password in active window after few seconds.


Thanks in advance

Sajan Patel
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) For Unix Forum
Do we have any other option then SCP but secure with authentication in which we can pass password with itself (like PSCP does)


If the client and server accounts trust each other -- meaning user at the client host can log into user at the server host without asking for another password, then this will solve your problem:

See ssh-keygen, to generate client and server key pair. Make sure that you don't use a passkey to encrypt the private key, and place the keys in the approprate files. The man pages for ssh-keygen should describe how to do this.

BTW, this does not eliminate the passwords, this just removes the need for a password to log into either account, once you logged into the other account.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!