How to do an rm through ssh - SSH

This is a discussion on How to do an rm through ssh - SSH ; Hello, everybody. I'm trying to set up a little bash script that will be fired regularly by the crond. It should connect over the Internet through SSH to another computer running Windows + cygwin + sshd, erase old backups and ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: How to do an rm through ssh

  1. How to do an rm through ssh

    Hello, everybody.

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

    The problem is that this line fails:

    ssh -i /root/.ssh/some_user-identity -p XXX some_user@AAA.BBB.CCC.DDD
    -s \
    "rm -fr /cygdrive/d/backup/$day_of_week/*"

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

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

    What's the meaning of that?
    This other line works OK. I guess that discards a lot of possibilities:

    scp -i /root/.ssh/some_user-identity -P XXX todays_backup.tar.gz \

    some_user@AAA.BBB.CCC.DDD:/cygdrive/d/backup/$day_of_week

    What's wrong?

    Thank's for your help:

    Wences


  2. Re: How to do an rm through ssh

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


    www.rsnapshot.org: The rsnapshot tool is your friend for this.





  3. Re: How to do an rm through ssh

    Wences wrote:

    > Hello, everybody.
    >
    > The problem is that this line fails:
    >
    > ssh -i /root/.ssh/some_user-identity -p XXX some_user@AAA.BBB.CCC.DDD
    > -s \
    > "rm -fr /cygdrive/d/backup/$day_of_week/*"
    >
    > ( $day_of_week is 1_Monday, 2_Tuesday, etc, and those directories exist
    > )
    > The error message says:
    >
    > Request for subsystem 'rm -fr /cygdrive/d/backup/4_Thursday/*' failed
    > on channel 0
    >
    > What's the meaning of that?


    Hello

    With -s you are requesting that ssh starts subsystem "your command and path"
    and it fails, maybe you can find out exact reason from server log. I have
    only used sftp subsystem and I don't know much about those.

    But anyway, there is no need for -s when you wan't to execute commands, just
    use:

    ssh -options some_user@host "command"

    Does this help?

    BR
    Kimmo Koivisto

  4. Re: How to do an rm through ssh

    "Wences" writes:

    >Hello, everybody.


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


    >The problem is that this line fails:


    >ssh -i /root/.ssh/some_user-identity -p XXX some_user@AAA.BBB.CCC.DDD
    >-s \
    > "rm -fr /cygdrive/d/backup/$day_of_week/*"


    Why the -s?
    Why all of the arguments?

    IF you are going to a unix computer,
    ssh user:machine.name name of the command
    will run the command name with arguements "of the command" on computer
    machine.name as user user.
    However I have no idea what would happen on a Windows machine. rm is not a
    windows command, - is not the windows argument designator.



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


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


    Yes, rm -fr ... is NOT a subsystem ( whatever that is.)


    >What's the meaning of that?
    >This other line works OK. I guess that discards a lot of possibilities:


    >scp -i /root/.ssh/some_user-identity -P XXX todays_backup.tar.gz \


    >some_user@AAA.BBB.CCC.DDD:/cygdrive/d/backup/$day_of_week


    What does -P XXX mean? that is not an option under openssh.


    >What's wrong?


    Too rococo a command line?


    >Thank's for your help:


    > Wences



  5. Re: How to do an rm through ssh

    >>>>> "WG" == Wences 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@AAA.BBB.CCC.DDD -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@qoxp.net


  6. Re: How to do an rm through ssh


    Nico Kadel-Garcia wrote:

    > www.rsnapshot.org: The rsnapshot tool is your friend for this.


    Hi, Nico,
    thanks for your suggestion, I will look into it, though I'm a bit
    skeptic because the main thing I want to backup is a Subversion
    repository, so the tar.gz files I actually upload are not really the
    same as in the local FS. First I need to export, or something the
    repository... but that's a different story...
    Thanks again:

    Wences


  7. Re: How to do an rm through ssh


    Kimmo Koivisto wrote:
    > But anyway, there is no need for -s when you wan't to execute commands, just
    > use:
    >
    > ssh -options some_user@host "command"
    >
    > Does this help?



    Ya bet it does!

    Yes that worked! I dropped the "-s" and it worked.

    Thanks a lot Kimmo.


  8. Re: How to do an rm through ssh


    Unruh wrote:
    > Why the -s?
    > Why all of the arguments?


    Well, the -s turned out to be in excess. The rest, I'm afraid, are
    needed.

    > However I have no idea what would happen on a Windows machine. rm is not a
    > windows command, - is not the windows argument designator.


    Well... it's Windows + Cygwin, so it counts almost like *IX. Cygwin is
    kinda a UNIX emulator for Windows, and OpenSSH runs inside it, so it's
    kind of in Unix. From the cygwin environment /cygdrive/c is your C:
    drive, etc...

    > Yes, rm -fr ... is NOT a subsystem ( whatever that is.)


    Yes, Richard Silvermans post made me see why.


    > >scp -i /root/.ssh/some_user-identity -P XXX todays_backup.tar.gz \

    >
    > >some_user@AAA.BBB.CCC.DDD:/cygdrive/d/backup/$day_of_week

    >
    > What does -P XXX mean? that is not an option under openssh.


    Well... scp uses -p for "preserve permissions", so it uses -P for the
    port number.
    The server listens on an exotic port number to add a bit of security
    through obscurity.

    > >What's wrong?

    >
    > Too rococo a command line?


    Hahahahaha! Yes, probably. But in the end, I did pull it off

    Thanks for your comments. I do appreciate them.
    Regards:

    Wences


  9. Re: How to do an rm through ssh


    Richard E. Silverman wrote:
    > 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@qoxp.net


    Hi, Richard,
    yes, that explains a lot of things. And it's a clever idea from
    the guys who made sshd also! I have this feeling I'll soon be finding
    all kinds of uses for it.
    Thanks for the explanation. Regards:
    Wences


+ Reply to Thread