Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
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.
has the original question been actually answered? Is there a way to use ssh (or mor urgent scp) with having the password in a file? I need to copy quite a lot of file to/from my work space, and for each scp I have to type my password. This is very annoying!
And yes, I have tried to setup the standard password-less ssh with keys, but for some unknown reasons this functionality is disabled. So the ONLY thing I can do is to stupidly type the same password dozen of times a day, except there is a way to do it with a password in a file...
has the original question been actually answered? Is there a way to use ssh (or mor urgent scp) with having the password in a file? I need to copy quite a lot of file to/from my work space, and for each scp I have to type my password. This is very annoying!
And yes, I have tried to setup the standard password-less ssh with keys, but for some unknown reasons this functionality is disabled. So the ONLY thing I can do is to stupidly type the same password dozen of times a day, except there is a way to do it with a password in a file...
Any help welcome.
Cheers
Alex
My suggestion would be to write a simple expect script...
Code:
#!/usr/bin/expect -f
set user username
set pass password
set host hostnameoripaddr
spawn ssh -l $user $host
expect "assword:"
send "$pass"
interact
This is off the top of my head and the syntax may need some tweaking, but you get the general idea.
I have tried to setup the standard password-less ssh with keys, but for some unknown reasons this functionality is disabled.
Trying to find out wouldn't hurt, wouldn't it?
Quote:
Originally Posted by alex170872
I need to copy quite a lot of file to/from my work space, and for each scp I have to type my password.
A password authenticates you as being a valid user on a local or remote system. Passwords often concern a personal account and certain privileges. Being careless about, giving away or otherwise making the password available to others may not be appreciated by remote admins. Ergo having a password in a script is not a good thing if someone else can read it. I suggest you try using ssh-agent before succumbing to using insecure kludges.
Being careless about, giving away or otherwise making the password available to others may not be appreciated by remote admins.
Yes I understand. But these remote admins DO NO ALLOW the usage of keys to log in!! They have disabled that feature due to some unknown reasons!
Nevertheless, with the example given in the post before that I googled I found a script which I have modified as follows:
Quote:
#!/usr/bin/expect -f
set source [lindex $argv 0]
set dest [lindex $argv 1]
set timeout -1
spawn scp $source user@host:$dest
set pass "whatever"
expect {
password: {send "$pass\r" ; exp_continue}
eof exit
}
This works so far fine to copy one file around, but when I use placeholders it does not work. Lets call the script 'scp_to_host' then the folling happens:
./scp_to_host "data_*" /home/user
spawn scp data_* user@host:/home/user
user@host's password:
'data_*': No such file or directory
Killed by signal 1.
Any ideas how to modify the script so that wildcards are accepted as well?
Tcl does not do filename expansion using the shell wildcard, but by means of the glob function. Once you've retrieved the list of files, you can use a for loop to copy each of them at a time:
Code:
#!/usr/bin/expect -f
set source [eval exec ls [glob [lindex $argv 0]]]
set dest [lindex $argv 1]
set timeout -1
set pass "whatever"
foreach file $source {
spawn scp $file user@host:$dest
expect {
password: {send "$pass\r" ; exp_continue}
eof
}
}
Maybe there is a better method in order to avoid the foreach loop, which iterates the scp command N times, but I'm not good at Tcl scripting!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.