Search code examples
unixsshsshpass

Remove file with Non-Interactive SSH Login


I'm trying to remote delete a file from a server with sshpass.

Using regular ssh works just fine:

ssh username@ip rm -f fullpath/file.txt
username@ip's password: ****

but when I try with sshpass:

sshpass -p 'password' username@ip rm -f fullpath/file.txt

server answer: sshpass: Failed to run command: No such file or directory

What am I missing??


Solution

  • Found it!

    sshpass -p 'password' ssh username@ip rm -f fullpath/file.txt