Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8156709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:02:38+00:00 2026-06-06T17:02:38+00:00

I know there is a lot of thread about this problem but I dont

  • 0

I know there is a lot of thread about this problem but I dont found right: I follow this example: Want to invoke a linux shell command from Java to run command. Problem with ssh command is in authentication. When I run it I need to set password

$ ssh root@server 'fgrep Exception *.log*' 
Enter passphrase for key '/././.ssh/id_rsa':

How can I pass here password ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:02:42+00:00Added an answer on June 6, 2026 at 5:02 pm

    There are libraries are available to invoke ssh. The Java Secure Channel (JSCH) is a very popular library, used by maven, ant and eclipse. It is open source with a BSD style license.

    If you need authentication for ssh, you can use through java.

    If your still need to by pass password passing, there are two ways to do what you want. One involves a stored password, and one does not.

    Both are non-interactive, meaning that they can work when you’re not there to enter a password.

    1. The way that does not require a password. You can use public/private
      key authentication instead of passwords with SSH. I’m going to
      assume that you’re using OpenSSH, which comes with practically every
      Linux distribution.

      Steps :

      • Configure your SSH server to accept private key logins. In /etc/ssh/sshd_config make sure that there’s a line that says PubkeyAuthentication yes (and that there is no # infront of it). If you change this file, you need to restart the sshd service.

      • On your local machine (not the server), create yourself a pair of keys with ssh-keygen -t rsa (you can use other options than rsa, but I’m keeping it simple). Do not specify a password. Save the keys in the locations prompted.

      • Open the contents of the id_rsa.pub file that you just created (it’s one very long line of text), and copy the contents into the end of the file $HOME/.ssh/authorized_keys on the server machine. Create the file if it doesn’t exist.

      Further Detail refer here.

    2. The basic idea is to use expect, which is an
      administration automation tool, to type your password in to ssh when
      prompted. It might not always work, and when it doesn’t, it’s hard
      to figure out why not. I recommend the first method.

      Anyway, here’s a command that you can poke at until it does what you
      want.

    The script Code is:

        expect -c 'spawn ssh user@remote.host ; expect assword ; send  "passphrase\n" ; interact'
    

    Expect might not be installed on your system. Make sure install that

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there's a lot of questions about this but I've been struggling with
I know that there are a lot of questions about this topic, but unfortunately
I know there a lot of similar questions to this, but I didn't find
I know there's a lot of resource for this via google, but I just
I know there is a lot of resources about that here but yet, I
Hey, There's a lot of posts on here about read barcodes but I want
I know there is a lot of controversy (maybe not controversy, but arguments at
I know there is a lot of talk about BPM these days and I
I know there's a lot of posts with the same that problem. I just
I know there are a lot of similar questions to this one around Stack

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.