Write a bash script for enter SSH password automatically.

Issues related to applications and software problems
Post Reply
hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Write a bash script for enter SSH password automatically.

Post by hack3rcon » 2019/06/22 07:04:15

Hello.
In an SSH connection, how can I write a bash script that enter the password automatically? I don't like to use a tool like "expect".

Thanks.

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Write a bash script for enter SSH password automatically.

Post by hunter86_bg » 2019/06/22 08:26:21

Why not using a key?

Anyway... This is a bad practice, as anyone can see the pass via 'strings'.

If you really insist:

Code: Select all

echo mypass  | ssh root@some.evil.place

User avatar
TrevorH
Site Admin
Posts: 33220
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Write a bash script for enter SSH password automatically.

Post by TrevorH » 2019/06/22 10:23:49

That is what ssh keys are for.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Write a bash script for enter SSH password automatically.

Post by aks » 2019/06/24 01:01:45

You could do it with the expect stuff, but yeah, don't.

Post Reply