Bash script : event not found when I echo my password into ssh
Hi all
I am automating some ssh connections on my laptop. I use this bash script: echo my!pass | ssh hostname I get this: -bash: !pass: event not found Well, my password contains ! and I really don't like to change it. What does this mean and how can I fix it? Please note: I can't use expect Error seen on SunOS and MAC El Capitan Thanks! |
Use single quotes to stop the shell from interpreting it.
|
Thank you,
I try bot ' and / In both cases, it skips everything after ' or / Even doesn't get to ssh. It just prints: echo my Any idea how to stop process and move on to processing after? Thanks |
Quote the command you tried and also the error message. Don't forget about [code] and [/code] tags.
eg [code] Code:
$ echo 'oh my!' PS: don't even try to use ssh this way. Use certificates. https://www.digitalocean.com/communi...up-ssh-keys--2 |
Many thanks
You are right, this is not the best idea :) However, servers are out of my hand so I should go with another way. |
Automating connections with ssh is better, safer with public/private key anyway...
Code:
ssh-keygen Then you add the contents of id_rsa.pub (assuming you created an rsa key) to the target server user's authorized keys. Code:
scp ~/.ssh/id_rsa.pub user@target.server:./my_pub_key.pub Then try: ssh user@target.server and you should see you can log on with no password, so no need to echo it plain-text in a script. |
All times are GMT -5. The time now is 03:01 PM. |