Re: How to do an rm through ssh



"WG" == Wences <wgrillo@xxxxxxxxx> writes:

WG> Hello, everybody. I'm trying to set up a little bash script that
WG> will be fired regularly by the crond. It should connect over the
WG> Internet through SSH to another computer running Windows + cygwin
WG> + sshd, erase old backups and create new ones.

WG> The problem is that this line fails:

WG> ssh -i /root/.ssh/some_user-identity -p XXX
WG> some_user@xxxxxxxxxxxxxxx -s \ "rm -fr
WG> /cygdrive/d/backup/$day_of_week/*"

WG> ( $day_of_week is 1_Monday, 2_Tuesday, etc, and those directories
WG> exist ) The error message says:

WG> Request for subsystem 'rm -fr /cygdrive/d/backup/4_Thursday/*'
WG> failed on channel 0

WG> What's the meaning of that?

A subsystem is a named service defined in the sshd configuration; -s means
to invoke a subsystem rather than run a remote command. You can use this
to hide the implementation of a service from the client, for abstraction.
For example:

--- [sshd_config] ----------------------------------------

subsystem backups /path/to/backup/script

----------------------------------------------------------

With this, you could use "ssh -s backups", and if the name of the backup
script changes, clients don't have to know.

The most common use of subsystems is for sftp.

--
Richard Silverman
res@xxxxxxxx

.