LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-15-2018, 02:01 PM   #1
reddany
LQ Newbie
 
Registered: Sep 2018
Posts: 1

Rep: Reputation: Disabled
how to run scp without a password


Hi,
I have a script in /etc/init.d that runs automatically when the PC starts.
This script wants to transfer a file that is on the server on my local PC, through the scp command.
I would like the script not to ask for the password when it is executed.
I saw on this forum that for the same problem it was suggested to create the public key and to copy it to the server.
I think I did correctly. but the script executed manually by the terminal, keeps asking for the password.

This is the command contained in the script:

Code:
scp -r danilo@192.168.1.24: / home / danilo / *. sql / home / danilo / backupsql /.
the key that I have generated in / home / danilo / is called
Quote:
miakey and miakey.pub
I copied miakey.pub on my server in / home / danilo

How can I change this command to run it SCP without password prompt ?

Thanks for the attention
danilo
 
Old 09-15-2018, 03:23 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: High Sierra
Posts: 9,224
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by reddany View Post

How can I change this command to run it SCP without password prompt ?

Thanks for the attention
danilo
Welcome to LQ danilo!

Most ssh utilities implement -i /path/to/key, so here's the syntax:
you said you
Quote:
Originally Posted by reddany View Post
I copied miakey.pub on my server in /home/ danilo
Change it. Which direction are you headed and from where?
That is not hard to figure out!
Short answer if I have to "make it work", and I were you, I'd be in physical possession (Copied to localhost) of the miakey on both hosts..
One hiccup, there may be a password in the key.

Code:
scp -i /home/danilo/miakey / home / danilo / *. sql / home / danilo / backupsql /. danilo@192.168.1.24
WHAT are you doing with this string, please?
Code:
/ home / danilo / *. sql / home / danilo / backupsql /.
Tip: Please don't use spaces inside [code][/code] tags. IDK WT heck that string is about. ;(
Looks like a suicide note.


Maybe.
Sorry if that's harsh
https://wiki.osuosl.org/howtos/ssh_key_tutorial.html

Last edited by Habitual; 09-15-2018 at 03:25 PM.
 
Old 09-15-2018, 03:31 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,481

Rep: Reputation: 2284Reputation: 2284Reputation: 2284Reputation: 2284Reputation: 2284Reputation: 2284Reputation: 2284Reputation: 2284Reputation: 2284Reputation: 2284Reputation: 2284
Welcome to LinuxQuestions.

There are many ssh private key guides that can be found by searching the web.

The default location for public and private keys is in your users ~/.ssh directory. The public key is copied to the servers authorized_keys file. You can use ssh-copy-id script which will copy the public key to the correct location on the server.

The distribution/version on your local PC is important because it depends on the init system it uses. While systemd is backwards compatible with init.d your script must comply with the standard LSB format and must be ran at the proper time such that networking has started.

A simpler method would be to run the script from a cron task at boot time or using rc.local.

https://help.ubuntu.com/community/SSH/OpenSSH/Keys
You do not need a passphrase.

Last edited by michaelk; 09-15-2018 at 03:32 PM.
 
  


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
How to specify password to scp? ASTRAPI Linux - Newbie 8 11-18-2014 10:10 PM
How to use scp with the password ? pradiptart Linux - Newbie 8 07-06-2012 01:50 AM
[SOLVED] ssh scp key not working to ssh/scp without password rjo98 Linux - Newbie 9 08-22-2011 04:28 PM
scp needs three times password in wrong password case!!! JATA01 Programming 6 12-01-2008 05:28 AM
SCP without Password help ignignokt Linux - Networking 3 01-02-2007 11:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:01 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