how to supply sftp with password? - SSH

This is a discussion on how to supply sftp with password? - SSH ; I need to send some files through SFTP to remote server. I am not an expert in SSH so I'll try to describe what I did and I hope someone kind will tell me what should I do next. I ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: how to supply sftp with password?

  1. how to supply sftp with password?

    I need to send some files through SFTP to remote server. I am not an
    expert in SSH so I'll try to describe what I did and I hope someone
    kind will tell me what should I do next. I live on AIX 5.3

    Server's admin gave me host name, user id and password.
    In shell I typed a command:
    bash-3.00$ sftp user@server
    SFTP responded that it can not establish server's authenticity and
    showed me "DSA key fingerprint", and asked do I still want to
    connect. I answered 'yes'. SFTP added server to the list of known
    hosts and prompt me for password.
    I typed the password - connection established. I was able to send all
    files I needed to send.

    Now I want to send my files from cron. But sftp always asks to type
    the password. I can not supply password nor through stdin, nor from
    batch file with commands.
    So what should I do?


  2. Re: how to supply sftp with password?

    White Owl wrote:
    > I need to send some files through SFTP to remote server. I am not an
    > expert in SSH so I'll try to describe what I did and I hope someone
    > kind will tell me what should I do next. I live on AIX 5.3
    >
    > Server's admin gave me host name, user id and password.
    > In shell I typed a command:
    > bash-3.00$ sftp user@server
    > SFTP responded that it can not establish server's authenticity and
    > showed me "DSA key fingerprint", and asked do I still want to
    > connect. I answered 'yes'. SFTP added server to the list of known
    > hosts and prompt me for password.
    > I typed the password - connection established. I was able to send all
    > files I needed to send.
    >
    > Now I want to send my files from cron. But sftp always asks to type
    > the password. I can not supply password nor through stdin, nor from
    > batch file with commands.
    > So what should I do?
    >


    Please look into using ssh-agent, preferably with the 'keychain' tool, to
    provide an SSH key, unlock it for your application, and limit its power on the
    target side to nominally safe operations. And read the manual pages on
    ssh-agent.

  3. Re: how to supply sftp with password?

    On Sep 5, 5:21*pm, Nico Kadel-Garcia wrote:
    > White Owl wrote:
    > > I need to send some files through SFTP to remote server. I am not an
    > > expert in SSH so I'll try to describe what I did and I hope someone
    > > kind will tell me what should I do next. I live on AIX 5.3

    >
    > > Server's admin gave me host name, user id and password.
    > > In shell I typed a command:
    > > bash-3.00$ sftp user@server
    > > SFTP responded that it can not establish server's authenticity and
    > > showed me "DSA key fingerprint", and asked do I still want to
    > > connect. *I answered 'yes'. SFTP added server to the list of known
    > > hosts and prompt me for password.
    > > I typed the password - connection established. I was able to send all
    > > files I needed to send.

    >
    > > Now I want to send my files from cron. But sftp always asks to type
    > > the password. I can not supply password nor through stdin, nor from
    > > batch file with commands.
    > > So what should I do?

    >
    > Please look into using ssh-agent, preferably with the 'keychain' tool, to
    > provide an SSH key, unlock it for your application, and limit its power on the
    > * target side to nominally safe operations. *And read the manual pages on
    > ssh-agent.


    I do not have 'keychain' tool. And I can not install any additional
    applications on my AIX.
    If I understand ssh-agent's man, I need to to define ~/.ssh/id_rsa
    and ~/.ssh/id_dsa, but I am unable to do so. I do not have access to
    the server at all!
    All I have is user id and password which I type in interactive sftp. I
    know that server is installed on some Windows box. Server does not
    accept me by ssh.


  4. Re: how to supply sftp with password?

    White Owl wrote:
    > On Sep 5, 5:21 pm, Nico Kadel-Garcia wrote:
    >> White Owl wrote:
    >>> I need to send some files through SFTP to remote server. I am not an
    >>> expert in SSH so I'll try to describe what I did and I hope someone
    >>> kind will tell me what should I do next. I live on AIX 5.3
    >>> Server's admin gave me host name, user id and password.
    >>> In shell I typed a command:
    >>> bash-3.00$ sftp user@server
    >>> SFTP responded that it can not establish server's authenticity and
    >>> showed me "DSA key fingerprint", and asked do I still want to
    >>> connect. I answered 'yes'. SFTP added server to the list of known
    >>> hosts and prompt me for password.
    >>> I typed the password - connection established. I was able to send all
    >>> files I needed to send.
    >>> Now I want to send my files from cron. But sftp always asks to type
    >>> the password. I can not supply password nor through stdin, nor from
    >>> batch file with commands.
    >>> So what should I do?

    >> Please look into using ssh-agent, preferably with the 'keychain' tool, to
    >> provide an SSH key, unlock it for your application, and limit its power on the
    >> target side to nominally safe operations. And read the manual pages on
    >> ssh-agent.

    >
    > I do not have 'keychain' tool. And I can not install any additional
    > applications on my AIX.
    > If I understand ssh-agent's man, I need to to define ~/.ssh/id_rsa
    > and ~/.ssh/id_dsa, but I am unable to do so. I do not have access to
    > the server at all!
    > All I have is user id and password which I type in interactive sftp. I
    > know that server is installed on some Windows box. Server does not
    > accept me by ssh.
    >


    OK, you need to find some good explanations. keychain is a perl script: it
    runs on the server that needs to log into others, and sets up an ssh-agent for
    you, and stores the settings for in in a text file that you can source so that
    you can use it later.

    What machine is running the cron jobs? And what privileges do you have on
    each? Can you install the '.ssh/authorized_keys' file on the target server?

  5. Re: how to supply sftp with password?

    On Sep 6, 3:17*am, Nico Kadel-Garcia wrote:
    > White Owl wrote:
    > > On Sep 5, 5:21 pm, Nico Kadel-Garcia wrote:
    > >> White Owl wrote:
    > >>> I need to send some files through SFTP to remote server. I am not an
    > >>> expert in SSH so I'll try to describe what I did and I hope someone
    > >>> kind will tell me what should I do next. I live on AIX 5.3
    > >>> Server's admin gave me host name, user id and password.
    > >>> In shell I typed a command:
    > >>> bash-3.00$ sftp user@server
    > >>> SFTP responded that it can not establish server's authenticity and
    > >>> showed me "DSA key fingerprint", and asked do I still want to
    > >>> connect. *I answered 'yes'. SFTP added server to the list of known
    > >>> hosts and prompt me for password.
    > >>> I typed the password - connection established. I was able to send all
    > >>> files I needed to send.
    > >>> Now I want to send my files from cron. But sftp always asks to type
    > >>> the password. I can not supply password nor through stdin, nor from
    > >>> batch file with commands.
    > >>> So what should I do?
    > >> Please look into using ssh-agent, preferably with the 'keychain' tool,to
    > >> provide an SSH key, unlock it for your application, and limit its power on the
    > >> * target side to nominally safe operations. *And read the manual pages on
    > >> ssh-agent.

    >
    > > I do not have 'keychain' tool. And I can not install any additional
    > > applications on my AIX.
    > > If I understand ssh-agent's man, I need to to define ~/.ssh/id_rsa
    > > and *~/.ssh/id_dsa, but I am unable to do so. I do not have access to
    > > the server at all!
    > > All I have is user id and password which I type in interactive sftp. I
    > > know that server is installed on some Windows box. Server does not
    > > accept me by ssh.

    >
    > OK, you need to find some good explanations. keychain is a perl script: it
    > runs on the server that needs to log into others, and sets up an ssh-agent for
    > you, and stores the settings for in in a text file that you can source sothat
    > you can use it later.
    >
    > What machine is running the cron jobs? And what privileges do you have on
    > each? Can you install the '.ssh/authorized_keys' file on the target server?


    I have a user-level access to the server named "RG" (which is AIX
    5.3), I can control crontab on it, but I can not install anything.
    Server I need to connect (named MSCVC, runing on Windows) allows me to
    do SFTP only.
    As far as I understand the SSH, to establish a password-less
    connection I need to create id_rsa and id_rsa.pub and put id_rsa on
    the server (in my case to the MSCVC) and id_rsa.pub should go into my
    ~/.ssh/ directory on RG. Is this correct?

  6. Re: how to supply sftp with password?

    White Owl wrote:

    > I have a user-level access to the server named "RG" (which is AIX
    > 5.3), I can control crontab on it, but I can not install anything.
    > Server I need to connect (named MSCVC, runing on Windows) allows me to
    > do SFTP only.
    > As far as I understand the SSH, to establish a password-less
    > connection I need to create id_rsa and id_rsa.pub and put id_rsa on
    > the server (in my case to the MSCVC) and id_rsa.pub should go into my
    > ~/.ssh/ directory on RG. Is this correct?


    If you have the ssh package installed (and you must if you are using
    sftp) you should also have ssh-keygen, ssh-agent, and ssh-add. You don't
    need any special permissions to create a keypair to use with ssh-agent
    or keychain (which is essentially just a wrapper for ssh-agent). You
    just need to create a .ssh directory in your $HOME directory on both
    servers and create the appropriate files.

    Generate a keypair with ssh-keygen. The key files are placed in ~/.ssh.
    Copy the *public* key file to the remote server and place it the
    ~/.ssh/authorized_keys file on the remote server. You might be tempted
    to create a public key without a passphrase. This would allow you to get
    by without using ssh-agent and caching the key - DONT DO IT. It may
    simplify things but is a bug security problem. If someone gets a copy of
    the key, they can masquerade as you until the cows come home.

    Cache the *private* key with ssh-agent, and start copying files.


    wikipedia has a decent explanation.

    http://en.wikipedia.org/wiki/Ssh-agent

  7. Re: how to supply sftp with password?

    I'm using an AIX an there is a command name expect. I used for move some file generate by the database to another computer, so I write a shell like this:

    #!/usr/bin/expect
    spawn sftp -b ArEn usrname@ip
    expect "*?assword:*"
    send "pasword\n"
    interact

    Is very simple for using spawn is part of the expect library if Im not wrong, AREn is a file that contain the names of all files that I need to send. And here it comes the magic you can write as many expects you need, what it means "*?assword:*" is if you find any word password not minding the case of the first letter the answer is what come next send "pasword\n" and the \n must be after all the answer y like given it a enter. The ArEn file is this way:

    cd submitfolder
    put "archivo1.txt"
    put "archivo2.dat"

    That is the file you can add as many files that you wan it to and the cd is for change the directory of where we wan to leave the files in the computer I hope this works for you.

    Andres

+ Reply to Thread