LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
 
Search this Thread
Old 03-03-2014, 01:42 AM   #1
har_85
LQ Newbie
 
Registered: Sep 2013
Posts: 11

Rep: Reputation: Disabled
scp using sshpass


Hi,

I need to copy files from a remote machine to a my machine using sshpass only, could you please help..

I am doing this:
sshpass -p "password" scp user@remote-machine:/home/QA.txt /home/faadmin/

i do not mind password being displayed in the script, also if the QA.txt file which needs to be copied from remote machine to my machine needs any particular permission or am i missing something in the above script, please advise.

Regards,
har_85
 
Old 03-03-2014, 05:28 AM   #2
mina86
Member
 
Registered: Aug 2008
Distribution: Slackware
Posts: 441

Rep: Reputation: 187Reputation: 187
Is there any reason why you are not using ssh keys? With a key authentication you are even able to limit where user is allowed to log from or what commands to run. There's plenty of tutorials on the net.
 
Old 03-03-2014, 06:33 AM   #3
har_85
LQ Newbie
 
Registered: Sep 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Yes..due to limitations on the server end sshpass is only to be used. I have found the solution, issue was due to "StrictHostKeyChecking" , I dis this and issue was resolved.

sshpass -p "password" scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r user@remote-machine:/home/QA.txt /home/faadmin/

Regards,
har_85
 
Old 03-03-2014, 10:06 AM   #4
mina86
Member
 
Registered: Aug 2008
Distribution: Slackware
Posts: 441

Rep: Reputation: 187Reputation: 187
All right then, but I hope you are aware this is as insecure as SSH can get. It's only marginally more secure then telnet.

Why is StrictHostKeyChecking an issue? You should be able to connect to the remote machine, let SSH add host key to known hosts file, and from that point on, your command should work just fine. Is your server regenerating keys all the time? What's going on here?
 
Old 03-03-2014, 11:12 PM   #5
har_85
LQ Newbie
 
Registered: Sep 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Yes, i understand the constraints of sshpass, I normally generate ssh keys and use "expect" to automate the scripts, but here i have no choice and had to use this and it works.
Thank you mina86, for all the suggestions, it made me work and think more on these ssh issues.

Regards,
har_85
 
Old 03-04-2014, 05:38 AM   #6
mina86
Member
 
Registered: Aug 2008
Distribution: Slackware
Posts: 441

Rep: Reputation: 187Reputation: 187
At this point my issue is not with sshpass. It's with “-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no”. This means that you have no man-in-the-middle attack protection. You could connect to NSA's mainframe and not notice. And I see no reason why those options would be required.

Have you tried logging in normally to the server and then using your sshpass command without those options?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: sshpass command : Non-interactive Password Authentication with SSH LXer Syndicated Linux News 0 08-27-2013 03:40 PM
Shell scp works perfectly, Net::SCP::Expect calls timing out - reasons? EnderX Programming 1 04-27-2013 01:35 AM
sshpass issue in executing commands in sftp Mode. pradeepdee6 Linux - Newbie 7 04-17-2013 09:18 AM
scp does not work and gives the following error message: scp: FATAL: Executing ssh1 i akay Linux - Networking 16 09-28-2008 11:41 PM
LXer: sshpass - Non-interactive ssh password authentication LXer Syndicated Linux News 0 05-04-2008 04:50 PM


All times are GMT -5. The time now is 02:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration