N
N
Nikita Spickiy2016-03-11 12:25:50
linux
Nikita Spickiy, 2016-03-11 12:25:50

Script for connecting via SSH, how to do it?

Good afternoon, I recently began to study Linux and this is the task that appeared. You need to write a script on the bash that will request the server address, login, password, connect to it, add rules to IP-tables, copy files via SCP to the right folder, install the right software and reboot the server. Is it real? What are the best materials to study?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Nagaets, 2016-03-11
@gr1mm3r

ask for server address, login, password, sub... For everything else Pyton and Bash

B
bamond, 2016-03-11
@bamond

My advice to you, study ansible))
Everything that you described is very easily done by him

M
Mystray, 2016-03-11
@Mystray

That's right - configure the keys and Ansible.
Wrong but works - sshpass
sshpass is a utility designed for running ssh using the mode referred to as "keyboard-interactive" password authentication
, but in non-interactive mode.
ssh uses direct TTY access to make sure that the password is indeed issued by an interactive keyboard user. Sshpass runs
ssh in a dedicated tty, fooling it into thinking it is getting the password from an interactive user.
The command to run is specified after sshpass' own options. Typically it will be "ssh" with arguments, but it can just
as well be any other command. The password prompt used by ssh is, however, currently hardcoded into sshpass.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question