Harish Harish - 1 year ago 60
Bash Question

Remove directory in a remote machine using shell script

I'm using Mac machine and I need to connect to remote machine(Linux) and remove the contents of a directory in the remote machine. Tried using

ssh root@server-address rm -rf testdir

It prompts me for the password in the terminal. Is there any way through which I can delete the contents of directory without having to manually enter the password for the remote machine? I want to do this using shell script. As I'm new to shell, any help would be appreciated.

Answer Source
ssh root@server-address "rm -rf testdir" #suggest you quote the command

looks fine.

You can work-around the password prompt by the steps mentioned [ here ].

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download