简体   繁体   中英

Linux expect command analog

While developing a shell script to copy logs from lots of remote servers, I found out a problem that I need to pass a password for each ssh connection to each server (and it makes me very nervous:) ). I know that it is better to use keys, but the process of adding them will take a lot of time due to our admins. As an option I found that it is possible to use the expect command, but it is not installed on our servers, and installation will take also a lot of time.

So, is it possible to simulate expect command behavior via plain shell scripts to pass passwords to ssh non-interactively?

If you have access to a compiler, you should be able to compile expect from source. If expect is difficult to compile, try empty , it's a very small and simple program - if anything compiles, it should, too. Here is an example of using it to automate ssh login.

Do note that others are right: ssh keys are your friends, while both expect and empty are usually just ugly and unsafe workarounds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM