ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Ubuntu based stuff for the most part
Posts: 1,173
Rep:
You need to set up a ssh key for the user doing the transfer.
Here is a howto that will help. Just don't use a password on the key if you are prompted for one when making it. http://pkeck.myweb.uga.edu/ssh/
Not considered setting up the ssh keys. I will give that a try.
However, I also wanted to know how to automate the script to paste in the password for me? The reason for this is I will have many different machines to log on to and need script this rather than log on to each and setup ssh keys.
Distribution: Ubuntu based stuff for the most part
Posts: 1,173
Rep:
If you use the same password, you could pass the password as a variable in the script, but that is very insecure since if someone can read the script then they have the password.
There is a way to compile a script into a binary, but I think that can be decompiled.
Yes i'd like to put the password into the script so to automatically give the password when prompted. But how?
Expect is the way to go, as was suggested by michaelk. But I'd strongly recommend against it. From a security standpoint, it's hideous....you're storing a plain-text password for another system, in (essentially), a text-file.
Setting up SSH keys is easier, too, and reduces your script to one line:
Code:
scp <file(s) to copy> <user id>@<remote system>:<destination directory>
like
scp -r /home/user myusername@111.222.333.444:/home/backups/user
Setup ssh keys and/or look at ssh-agent, which asks you the passwd once, then stores it in memory and your ssh tools prog (eg scp) get it from there until you logout of the local the session.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.