Sonique
Sonique

Reputation: 7080

shell script - open ssh connect and send commands when needed

Is it possible to open ssh connect in bash script and send commands through it when it needed.

I want to put some logic between commands and use one connection.

Upvotes: 2

Views: 1494

Answers (1)

Cyrus
Cyrus

Reputation: 88583

With a here document:

#!/bin/bash

ssh user@server << EOF
echo $HOSTNAME 
hostname
echo Hello
EOF

Upvotes: 1

Related Questions