0

I need to download a file over SSH (scp) from Ubuntu machine A to ubuntu machine B.

I don't have a root access on the machine from I am downloading the file (machine B), so I cannot install anything like sshpass etc...Just clear Ubuntu.

I need to use password authentication because the command will be called inside TeamCity plugin which does not support downloading over SSH (just uploading) or plain bash. I don't have priviledge to read SSH private keys from command line.

Tomas Kubes
  • 23,880
  • 18
  • 111
  • 148
  • I don't really understand your question. Can't you just run the usual scp command? (scp host:/path/to/file ./) sshpass should not be required, and password authentication should not change anything – Cydouzo Nov 27 '19 at 07:21
  • 1
    @Cydouzo Command ask for password interactivelly. I need to automated it, so I need a workaround how to provide the password to scp from commandline. – Tomas Kubes Nov 27 '19 at 09:30
  • You can do that using expect. It should not require admin rights if you don't touch anything outside the home repo. This thread contains some examples of how to do that. Hope it can help https://stackoverflow.com/questions/12202587/automatically-enter-ssh-password-with-script – Cydouzo Nov 27 '19 at 09:49
  • @Cydouzo. I tried, I am not allowed to copy to /usr/bin without sudo. Can I execute the script from different folder? – Tomas Kubes Nov 27 '19 at 10:08
  • Work with the administrator to install the proper keys. Just because *you* don't have permission to install them doesn't mean that's not the right thing to do here. – chepner Nov 27 '19 at 18:29
  • I have a SSH keys, but I cannot use them because of TeamCity design. In TeamCity, you can pass a SSH key to SSH Exec or SSH Upload, nothing else. Everything else must be written in commandline. – Tomas Kubes Nov 28 '19 at 09:09

1 Answers1

1

Finally, I found that Docker is a solution for it. I was lucky that docker is installed on this machine and I can install anything (including scp) inside docker even if I am not root on the host machine.

Tomas Kubes
  • 23,880
  • 18
  • 111
  • 148