V
V
Vitaly2016-08-29 10:20:43
linux
Vitaly, 2016-08-29 10:20:43

How to connect via ssh using a script?

All the best.
Please tell me, is it possible to somehow connect via ssh with password parameters and confirmations on the key record?
something like this: ssh [email protected]_host -password -yes
I want to write a small script that will copy the file via scp , but without asking for a password and writing to the list of keys.
The option of connecting by key is not entirely suitable, since the script will be run on different machines and downloads will also be from different machines

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Chelyuk, 2016-08-29
@Chelyuk

For these purposes, there are several special utilities. One of the most well-known is expect(pexpect - for Python, etc. for other languages) which can be used to connect, send commands, parse, and wait for specific responses. Although, for such a simple task as just transferring a file via SCP, I would use connecting a remote media via scp and any script / tool for copying the file. Then you can work with the connected media as with a local one.

A
Alexander Chernykh, 2016-08-29
@sashkets

I'll add 5 cents too.
if the key option is not suitable (IMHO the easiest for your case) I have a backup using stunnel and rsync.
But it's easier with keys

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question