I need to run a script located in a directory on remote server by using ssh authentication from my local unix server. Can anyone help me in this.
I have tried the below command. It worked for echo command but when i tried to open a file using cat command it is showing "cat: cannot open the <filename>". I have given the required permissions as well.
ssh <username>@<ipaddress> cd <path>;cat <filename>
The problem here is that the cat is running locally. Your local shell is seeing the semicolon as a command separator between the ssh command and the cat command. Try quoting the command string to send it to the remote side eg:
Remote server will have same permissions to the filesystem that the "username" user has.
Why not try running the command from an interactive shell you can then debug/sort out required permissions:
$ ssh username@ipaddress
Last login: Fri Jan 30 16:19:27 2015 from your-pc.your.domain
ipaddress $ cat /path-to-file/file
This is the file contents
ipaddress $ exit
Connection to ipaddress closed.
$