Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java program sshing to Linux Server

 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write a java program and eventually a web app to do the following.

1. get the server name, username, password from the user and ssh to the linux box.

2. goto a folder, open a script file (the file has different function calls, I need to comment all other function calls and just un-comment the one I want to use)

#call_1
call_2
#call_3
#call_4

I know it should always use the call_2 for this, but other programs or users can comment/uncomment these calls. So I need to make sure of it.

3. Execute the nohup command to run the script
4. May be (this is to be decided) send an email once its done.

I think we can do this from a java program, but not sure about the step 2. Do we need a script for that?

I started using JSch - Java Secure Channel, but I get "com.jcraft.jsch.JSchException: Auth fail". I found that I need to change /etc/ssh/sshd_config file. But for me that is not an option because of compliance issues. So how else can I go about this.

Any help is appreciated. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic