Professional Web Applications Themes

Remote Execution Through FTP - Linux / Unix Administration

hi guys, How are you all??? I have a small issue. The details are: I need to send some file from my local machine to a remote machine (different user name) I can use FTP for this. Sounds easy huh? here comes the issue, before sending the file i need to check if the remote machine has enough space to recieve the file. doing du i ll get the free space, but i cannot run du from ftp prompt. neither can i do an rlogin, telnet etc etc... All these operations i have to do in script. Even if i ...

  1. #1

    Default Remote Execution Through FTP

    hi guys,

    How are you all???

    I have a small issue. The details are:

    I need to send some file from my local machine to a remote machine
    (different user name)
    I can use FTP for this.

    Sounds easy huh?
    here comes the issue,
    before sending the file i need to check if the remote machine has
    enough space to recieve the file. doing du i ll get the free space, but
    i cannot run du from ftp prompt.

    neither can i do an rlogin, telnet etc etc...

    All these operations i have to do in script.

    Even if i can use rlogin, telnet or anything else, how can i use it
    without a password prompt.

    I tried editing ~/.rhosts and also please put some light on key
    generation mechanism in SSH.

    Please help

    Anoop Guest

  2. #2

    Default Re: Remote Execution Through FTP

    In article <googlegroups.com>,
    "Anoop" <co.in> wrote:
     

    Some versions of ftp servers will allow for SITE EXEC commands which
    might offer you what you're looking for. You have to check with the
    sysadmin of the remote machine to find out what ftp server they're
    running and if they'll allow you to run something like "site exec df ."
    or du or some script they provide to show you how much space is left on
    the filesystem. Be aware that some ftp servers consider SITE EXEC a
    massively Bad Idea(tm) and a major security issue. You may have to
    rethink your approach to doing this sort of thing if all you have for
    file transfer is FTP.

    Some ftp servers limit transfer either by file or the amount of data
    transferred. Again check with the admin on the remote system.

    --
    DeeDee, don't press that button! DeeDee! NO! Dee...



    Michael Guest

  3. #3

    Default Re: Remote Execution Through FTP

    thanks michael,

    but it would be of more help if you could help me with the following:

    Even if i can use rlogin, telnet or anything else, how can i use it
    without a password prompt from a script.

    I tried editing ~/.rhosts and also please put some light on key
    generation mechanism in SSH.

    Please help

    Anoop Guest

  4. #4

    Default Re: Remote Execution Through FTP

    for remote copying i always use

    "scp" secure copy which allow also local to remote machine copying
    covered by secure layer.
    /interactive or key AA procedure/

    ad_ftp: most clients have options to execute the "shell" commands
    man your favorite ftp client and search for it.
    instead of "ls" "!ls" so "df -k" will be in my enviroment "!df -k" to
    check the free space...

    So i don't know your ENV so i really don't know if my hint applies to
    yours issue.
    Cheers

    veehell Guest

  5. #5

    Default Re: Remote Execution Through FTP

    On 20 Jan 2006 02:00:51 -0800, Anoop wrote:
     

    ftp is a bad choice for scripting as you are finding out. Use the security
    argument to convince the powers that be to let you install ssh and scp,
    then you can script this quite easily using public key's to authenticate.
    I can see from other posts that you are interested in this method of
    operation, so I will briefly cover it here...

    First install the ssh client on the machine where the script is going to
    run.
    Then install the ssh daemon on the other machine.
    Create a key pair using ssh-keygen. When prompted for a passphrase for the
    pair of keys just hit enter, you don't want this key to be protected.

    In the home directory on the server with the daemon you should see a .ssh
    directory (may be .ssh2 depending on the flavour of ssh you install).
    Add the PUBLIC key (usually has a .pub file extension) to the
    authorized_keys file in the .ssh directory. How you do this will depend on
    the ssh flavour, you either put the text of the key into the file or you
    put the name of the file holding the key into the authorized keys file).
    Make sure the permissions on the .ssh directory and all the files in it are
    as restrictive as possible (check the man page, ssh will complain if you
    get this wrong).
    Then on the client machine, copy the PRIVATE key to use as an identity.
    Either you can copy this into the .ssh directory in the correct format to
    use as your identity or you can explicitly reference this key on the
    command line to the ssh command. Again take care with the permissions.
    Then from the command line on the client machine, try to log into the
    remote machine using ssh and the identity you created above.
    If things are going well, then the first time you try to connect you will
    be warned that your local machine doesn't know about the remote machine and
    you will be asked if you want to add the remote machine to the known_hosts
    file. Assuming your network is secure then this is exactly what you want to
    do or you will get asked this question each time you connect. Since you
    cannot easily script the answer of this question that would be bad.
    Once you can log in to the remote machine without a password, then you can
    try using ssh to run commands on the remote machine e.g. ssh remote "df -k"
    If all of this is working then you can use scp to copy files back and forth
    without any worries.
    Adam
    Adam Guest

  6. #6

    Default Re: Remote Execution Through FTP

    In article <googlegroups.com>,
    Anoop <co.in> wrote: 

    I don't know how you can tell in advance with FTP. However, you can
    get a directory listing _after_ you send your file and see if the size
    matches. In addition, FTP may give you an error message you can look for
    if it runs out of space.

    Ted
    ted@loft.tnolan.com Guest

  7. #7

    Default Re: Remote Execution Through FTP

    Adam Price <adam+co.uk> wrote in
    news:co.uk:
     
    >
    > ftp is a bad choice for scripting as you are finding out. Use the
    > security argument to convince the powers that be to let you install
    > ssh and scp, then you can script this quite easily using public key's
    > to authenticate. I can see from other posts that you are interested in
    > this method of operation, so I will briefly cover it here...
    >
    > First install the ssh client on the machine where the script is going
    > to run.
    > Then install the ssh daemon on the other machine.
    > Create a key pair using ssh-keygen. When prompted for a passphrase for
    > the pair of keys just hit enter, you don't want this key to be
    > protected.
    >
    > In the home directory on the server with the daemon you should see a
    > .ssh directory (may be .ssh2 depending on the flavour of ssh you
    > install). Add the PUBLIC key (usually has a .pub file extension) to
    > the authorized_keys file in the .ssh directory. How you do this will
    > depend on the ssh flavour, you either put the text of the key into the
    > file or you put the name of the file holding the key into the
    > authorized keys file). Make sure the permissions on the .ssh directory
    > and all the files in it are as restrictive as possible (check the man
    > page, ssh will complain if you get this wrong).
    > Then on the client machine, copy the PRIVATE key to use as an
    > identity. Either you can copy this into the .ssh directory in the
    > correct format to use as your identity or you can explicitly reference
    > this key on the command line to the ssh command. Again take care with
    > the permissions. Then from the command line on the client machine, try
    > to log into the remote machine using ssh and the identity you created
    > above. If things are going well, then the first time you try to
    > connect you will be warned that your local machine doesn't know about
    > the remote machine and you will be asked if you want to add the remote
    > machine to the known_hosts file. Assuming your network is secure then
    > this is exactly what you want to do or you will get asked this
    > question each time you connect. Since you cannot easily script the
    > answer of this question that would be bad. Once you can log in to the
    > remote machine without a password, then you can try using ssh to run
    > commands on the remote machine e.g. ssh remote "df -k" If all of this
    > is working then you can use scp to copy files back and forth without
    > any worries. Adam
    >[/ref]

    Adam, that's a clear and very well written reply, and should mostly
    satisfy the needs of the OP. For security's sake, since the ssh private
    *is* going to be used without a passphrase, I would add to your
    suggestions my own, being that a new, non-priviledged user account is
    created on the remote system, and that the key-pair is set up for this
    account. This way, the implementation of the script doesn't leave a
    gaping hole into the remote system if the client system were to be
    compromised.

    Best of luck,
    Nathanael Hoyle
    Nathanael Guest

  8. #8

    Default Re: Remote Execution Through FTP

    On 21 Jan 2006 19:16:25 GMT, Nathanael Hoyle wrote:
     
    >>
    >> ftp is a bad choice for scripting as you are finding out. Use the
    >> security argument to convince the powers that be to let you install
    >> ssh and scp, then you can script this quite easily using public key's
    >> to authenticate. I can see from other posts that you are interested in
    >> this method of operation, so I will briefly cover it here...
    >>
    >> First install the ssh client on the machine where the script is going
    >> to run.
    >> Then install the ssh daemon on the other machine.
    >> Create a key pair using ssh-keygen. When prompted for a passphrase for
    >> the pair of keys just hit enter, you don't want this key to be
    >> protected.
    >>
    >> In the home directory on the server with the daemon you should see a
    >> .ssh directory (may be .ssh2 depending on the flavour of ssh you
    >> install). Add the PUBLIC key (usually has a .pub file extension) to
    >> the authorized_keys file in the .ssh directory. How you do this will
    >> depend on the ssh flavour, you either put the text of the key into the
    >> file or you put the name of the file holding the key into the
    >> authorized keys file). Make sure the permissions on the .ssh directory
    >> and all the files in it are as restrictive as possible (check the man
    >> page, ssh will complain if you get this wrong).
    >> Then on the client machine, copy the PRIVATE key to use as an
    >> identity. Either you can copy this into the .ssh directory in the
    >> correct format to use as your identity or you can explicitly reference
    >> this key on the command line to the ssh command. Again take care with
    >> the permissions. Then from the command line on the client machine, try
    >> to log into the remote machine using ssh and the identity you created
    >> above. If things are going well, then the first time you try to
    >> connect you will be warned that your local machine doesn't know about
    >> the remote machine and you will be asked if you want to add the remote
    >> machine to the known_hosts file. Assuming your network is secure then
    >> this is exactly what you want to do or you will get asked this
    >> question each time you connect. Since you cannot easily script the
    >> answer of this question that would be bad. Once you can log in to the
    >> remote machine without a password, then you can try using ssh to run
    >> commands on the remote machine e.g. ssh remote "df -k" If all of this
    >> is working then you can use scp to copy files back and forth without
    >> any worries. Adam
    >>[/ref]
    >
    > Adam, that's a clear and very well written reply, and should mostly
    > satisfy the needs of the OP. For security's sake, since the ssh private
    > *is* going to be used without a passphrase, I would add to your
    > suggestions my own, being that a new, non-priviledged user account is
    > created on the remote system, and that the key-pair is set up for this
    > account. This way, the implementation of the script doesn't leave a
    > gaping hole into the remote system if the client system were to be
    > compromised.
    >
    > Best of luck,
    > Nathanael Hoyle[/ref]

    That makes lots of sense. You could also restrict the access of the
    transfer account with some tricks in the .profile etc.
    I didn't bother to elaborate on the security too much since the starting
    point was that ftp was secure enough.
    Adam
    Adam Guest

Similar Threads

  1. Remote.pm (File::Remote) error handling question
    By terminlman@yahoo.com in forum PERL Modules
    Replies: 3
    Last Post: January 31st, 07:26 PM
  2. Remote.pm (File::Remote) problem
    By Dayton Jones in forum PERL Modules
    Replies: 9
    Last Post: March 3rd, 01:12 AM
  3. Replies: 19
    Last Post: July 14th, 07:15 PM
  4. Remote script execution
    By Aman Thind in forum PERL Beginners
    Replies: 6
    Last Post: February 6th, 09:23 AM
  5. Setting folder permissions on remote machine / remote domain
    By Tim Chandler in forum ASP.NET Security
    Replies: 0
    Last Post: October 7th, 04:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139