Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Smile write a shell script that will remote login to machineB from machineA

    I wanna write a shell script which will do remote login to a machine,
    If I use ssh command to do that, It asks something like 'do you wanna continue (yes/no)' and then remote machine's password, so
    there we need to input yes and next input is remote machine's password. So my doubt is,
    how to give those two input(yes and remote machine's password) to the system? Can I use the below command

    echo 'yes abcd' | ssh --stdin user25at192.168.1.1

    where 'abcd' is the password of 'user25'(user25 is an user on remote machine')

    or I need to give input from file????

    Thanks in advance...

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    hi and welcome

    ssh does not ask if you want to login.
    If you login to a machine for the first time, ssh asks if you want to add the machine to the known_hosts file.

    As for the password: You dont want to have it in a plain text file.
    Because everyone with access to your pc can read it.

    My suggestion would be: Create a keypair for your user, of course with a passphrase on your private key, and establish a key based authentication to other hosts.

    (be sure to create a good passphrase)
    ssh-copy-id user25@
    Then you can use ssh without a password
    For a new session, the ssh-agent will ask for your passphrase once.
    You must always face the curtain with a bow.

  3. #3
    Hiii....Thanks a lot for your reply.....I got some knowledge on 'ssh key'..... but

    Suppose a command needs two argument to be inputted for its execution. so how to input those two arguments????
    CAN I USE echo along with two arguments before pipe symbol like below example????
    ex:- echo 'argument1 argument2' | command

    If I can't, Is there any way to input 2 arguments(for a command) in a single line???????

  4. $spacer_open
  5. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Not directly, because the pipe will send the stdout of echo to the stdin of the next command.
    You could use the comand xargs inbetween.

    Other than that, one questionmark per question is sufficient.
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts