UNIX ssh script, running commands on remote server UNIX ssh script, running commands on remote server unix unix

UNIX ssh script, running commands on remote server


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


Also, if you don't want to have a script available on the remote server, try the following:

ssh thehost 'cd /tmp; ls; echo Hello world, I am `hostname`'

and for SCP-less copying:

ssh localhost 'cat /bin/bash' > local_bash


If your goal is only to transfer files, you should use scp. But to execute some commands on the remote host without having a specific script on that remote host, you can simply use the stdin like this:

!/bin/shssh -o PreferredAuthentications=publickey brjones@server.com << EOTcd ~/folderecho "hello" > hello.txt...EOT