How to transfer data remotely to PCs in LAN via SFTP? - Networking

This is a discussion on How to transfer data remotely to PCs in LAN via SFTP? - Networking ; Hi, I want to automate transferring file or folder to 20 PCs connected via the same LAN.. The problem i face is that they need to enter password and i don't know how to pass it in the code syntax.. ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: How to transfer data remotely to PCs in LAN via SFTP?

  1. How to transfer data remotely to PCs in LAN via SFTP?

    Hi,

    I want to automate transferring file or folder to 20 PCs connected via
    the same LAN..

    The problem i face is that they need to enter password and i don't
    know how to pass it in the code syntax..

    Sample Code:
    for i in (1:20) # 20 PCs
    do
    sftp user(at)10.0.0.$i # to log-in remotely to PCs one by one
    # Password should be entered here!! How to ??
    put $file ; # transfer the file to destination PC
    exit # come back to current shell
    done # will go to log-in to the next PC

    I want to either override password promot, or find a way to pass it
    automatically to the standard input ..

    P.S. I have the root password and everything.

    Can anyone help me please? I'm not a programmer in fact, so if you see
    that my code is weak, please correct it to me..

    Thanks in advance,
    Ahmad,


  2. Re: How to transfer data remotely to PCs in LAN via SFTP?

    > The problem i face is that they need to enter password and i don't
    > know how to pass it in the code syntax..


    The last thing you want to do is put a cleartext password in a shell
    script. If you want maximum security, use ssh-agent (Read The Fine
    Manual page; it tells you everything you need to know). Using a key
    with no passphrase (Read The Fine Manual page for ssh-keygen) or a
    ~/.shosts file will also do what you want, though with less security.
    It all depends on your environment: how well the hosts can trust each
    other etc.

  3. Re: How to transfer data remotely to PCs in LAN via SFTP?

    On Mar 22, 7:19 am, "Ahmad" wrote:
    > Hi,
    >
    > I want to automate transferring file or folder to 20 PCs connected via
    > the same LAN..
    >
    > The problem i face is that they need to enter password and i don't
    > know how to pass it in the code syntax..
    >
    > Sample Code:
    > for i in (1:20) # 20 PCs
    > do
    > sftp user(at)10.0.0.$i # to log-in remotely to PCs one by one
    > # Password should be entered here!! How to ??
    > put $file ; # transfer the file to destination PC
    > exit # come back to current shell
    > done # will go to log-in to the next PC
    >
    > I want to either override password promot, or find a way to pass it
    > automatically to the standard input ..
    >
    > P.S. I have the root password and everything.
    >
    > Can anyone help me please? I'm not a programmer in fact, so if you see
    > that my code is weak, please correct it to me..
    >
    > Thanks in advance,
    > Ahmad,


    google for "passwordless ssh" to set up your ssh key authentication .
    sftp uses ssh to transfer files. If you want to do this as root ( and
    still disable direct logins as root the directive in sshd_config you
    need to use is "PermitRootLogin without-passwowrd "( after setting up
    the ssh keys for the root user that is..)..





  4. Re: How to transfer data remotely to PCs in LAN via SFTP?

    On Mar 22, 3:56 pm, "Kalyan Manchikanti"
    wrote:
    > On Mar 22, 7:19 am, "Ahmad" wrote:
    >
    >
    >
    > > Hi,

    >
    > > I want to automate transferring file or folder to 20 PCs connected via
    > > the same LAN..

    >
    > > The problem i face is that they need to enter password and i don't
    > > know how to pass it in the code syntax..

    >
    > > Sample Code:
    > > for i in (1:20) # 20 PCs
    > > do
    > > sftp user(at)10.0.0.$i # to log-in remotely to PCs one by one
    > > # Password should be entered here!! How to ??
    > > put $file ; # transfer the file to destination PC
    > > exit # come back to current shell
    > > done # will go to log-in to the next PC

    >
    > > I want to either override password promot, or find a way to pass it
    > > automatically to the standard input ..

    >
    > > P.S. I have the root password and everything.

    >
    > > Can anyone help me please? I'm not a programmer in fact, so if you see
    > > that my code is weak, please correct it to me..

    >
    > > Thanks in advance,
    > > Ahmad,

    >
    > google for "passwordless ssh" to set up your ssh key authentication .
    > sftp uses ssh to transfer files. If you want to do this as root ( and
    > still disable direct logins as root the directive in sshd_config you
    > need to use is "PermitRootLogin without-passwowrd "( after setting up
    > the ssh keys for the root user that is..)..

    Hi,
    This was my first post to this wonderfull forum!
    I really got tired searching and trying to remotely transfer data to
    group of PCs on a LAN using a shell script to perform passwordless
    sftp transmission..
    I am looking for help from someone that can give me the 1,2,3,.. steps
    to do it.
    And i am not a linux expert,
    My problem is:
    I want to make a script (function) that takes file path on current
    host (i work on) and then loops on 20 PCs that has IPs from 10.10.13.1
    through 10.10.13.20 and copy that file to the "user" homes.

    How can i do it (please in details)
    I know it may be bad to ask for that, but it's really urgent and i'm
    not specialized in doing such stuff!!

    BTW, I already googled and did my best, and tried somethings, but
    unfortunately, all stuff failed to achieve what i seek!!!

    Thanks a lot in advance,
    Ahmad,


  5. Re: How to transfer data remotely to PCs in LAN via SFTP?

    Ahmad wrote:

    As Kalyan says, you need to set up ssh using RSA authentication. There
    are good explanations on the web. Then, depending on what you want to do:

    scp -r directorytotransfer host1:/home/todirectory/

    or

    rsync -vaxe ssh directorytotransfer host1:/home/todirectory/

    Mark Atherton

  6. Re: How to transfer data remotely to PCs in LAN via SFTP?

    Ahmad wrote:
    > On Mar 22, 3:56 pm, "Kalyan Manchikanti"
    > wrote:
    >> On Mar 22, 7:19 am, "Ahmad" wrote:
    >>
    >>
    >>
    >>> Hi,
    >>> I want to automate transferring file or folder to 20 PCs connected via
    >>> the same LAN..
    >>> The problem i face is that they need to enter password and i don't
    >>> know how to pass it in the code syntax..
    >>> Sample Code:
    >>> for i in (1:20) # 20 PCs
    >>> do
    >>> sftp user(at)10.0.0.$i # to log-in remotely to PCs one by one
    >>> # Password should be entered here!! How to ??
    >>> put $file ; # transfer the file to destination PC
    >>> exit # come back to current shell
    >>> done # will go to log-in to the next PC
    >>> I want to either override password promot, or find a way to pass it
    >>> automatically to the standard input ..
    >>> P.S. I have the root password and everything.
    >>> Can anyone help me please? I'm not a programmer in fact, so if you see
    >>> that my code is weak, please correct it to me..
    >>> Thanks in advance,
    >>> Ahmad,

    >> google for "passwordless ssh" to set up your ssh key authentication .
    >> sftp uses ssh to transfer files. If you want to do this as root ( and
    >> still disable direct logins as root the directive in sshd_config you
    >> need to use is "PermitRootLogin without-passwowrd "( after setting up
    >> the ssh keys for the root user that is..)..

    > Hi,
    > This was my first post to this wonderfull forum!
    > I really got tired searching and trying to remotely transfer data to
    > group of PCs on a LAN using a shell script to perform passwordless
    > sftp transmission..
    > I am looking for help from someone that can give me the 1,2,3,.. steps
    > to do it.
    > And i am not a linux expert,
    > My problem is:
    > I want to make a script (function) that takes file path on current
    > host (i work on) and then loops on 20 PCs that has IPs from 10.10.13.1
    > through 10.10.13.20 and copy that file to the "user" homes.
    >
    > How can i do it (please in details)
    > I know it may be bad to ask for that, but it's really urgent and i'm
    > not specialized in doing such stuff!!
    >
    > BTW, I already googled and did my best, and tried somethings, but
    > unfortunately, all stuff failed to achieve what i seek!!!
    >
    > Thanks a lot in advance,
    > Ahmad,



    http://www.mattfoster.clara.co.uk/ssh-pam.htm

    That's a Step-by-Step tutorial which explains what you have to do for a
    passwordless ssh-login/scp-transfer.

    Matthias

+ Reply to Thread