Results 1 to 4 of 4
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-29-2013 #1
- Join Date
- Jun 2013
write a shell script that will remote login to machineB from machineA
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 192.168.1.1')
or I need to give input from file????
Thanks in advance...
- 06-29-2013 #2
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.
ssh-keygen (be sure to create a good passphrase) ssh-copy-id email@example.com
For a new session, the ssh-agent will ask for your passphrase once.You must always face the curtain with a bow.
- 06-29-2013 #3
- Join Date
- Jun 2013
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???????
- 06-29-2013 #4
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.