Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UNIX ssh script, running commands on remote server

I would like to create a script that automatically logs into a remote server and grabs a file on the server. The script already logs into the server however the commands are not run on that machine. Once I disconnect from the remote server, the commands are run on the client machine.

!/bin/sh
ssh -o PreferredAuthentications=publickey [email protected]
cd ~/folder
"i would like to grab file and copy it to client machines folder"

EDIT: I am not sure if you noticed but I am used a passwordless connection to the remote server using ssh and keygeneration. I appreciate the ideas but I am looking to possibly pipe commands or run commands on the remote server with the script on the client. I realize that the remote server does not have access to the client script, however I was curious if it was possible to pipe the commands through the ssh connection.

like image 481
user123661 Avatar asked Jun 16 '09 12:06

user123661


Video Answer


1 Answers

You should be using scp ("secure copy") rather than ssh ("secure shell").

like image 76
RichieHindle Avatar answered Oct 28 '22 16:10

RichieHindle