Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
I have successfully SCPd files back and forth using commands like the one below:
Code:
scp -P 2211 -r myname@www.mysite.com:/*tar.gz /
I would then enter my password for www.mysite.com and the xfer begins.
I now need to SCP files from my host, who insist on using an SSH key pair. I have the SSH keys all set up and have SSHd into the site fine, however how do I use this with the SCP command?
I thought the first time you tried to either use SSH or SCP that it would exchange keys and then you have the option to accept or reject them.
Once that is completed between hosts, and approved, they should be all set to do either SSH or SCP. I'd suggest you try your SCP command and see if it is all set, because my suspicion is that since you have successfully done SSH, the keys are already set up.
Exactly the same. You can create a ssh client config file (~/.ssh/config) to save options i.e.
Code:
host myserver
hostname www.mysite.com
port 2211
user myname
And then from the command line
ssh myserver
or
scp -r myserver:/*tar.gz /
Just like ssh scp will automatically try sending the default key i.e. id_rsa etc. If the key file is named something else then it needs to be specified on the command line or in the config file.
The first time you log in and accept is the host key i.e what is saved in known_hosts.
You can take that a step further and actually specify which key to use.
Code:
host myserver
hostname www.mysite.com
port 2211
user myname
identityfile /home/entropy1024/.ssh/mysite_key_rsa
See "man ssh_config" for the details on all the options.
But just to pick a nit, the actual keys never get sent. The private key, in particular, never leaves your machine. What happens in the case of key-based authentication is that the server uses the stored public key for that account and generates a challenge. If the account connecting to the server has the right private key it can decode the challenge and include it with a hashed response. If the response checks out ok then the server goes ahead with login.
Last edited by Turbocapitalist; 07-27-2017 at 07:33 AM.
The initial prompt about "the identity of the site," when you connect to a new site for the first time, is intended to deter imposters ... to detect if some server is impersonating the one you thought you were connecting to. Subsequent connects to the site are expected to return the same random key and to use the same IP.
SCP uses SSH as its communication protocol, and adds file-copying on top of that.
Remember the usual rules about SSH and certificates, such as the fact that the requirements for directory and file permissions.
It is much more secure to use certificates ... and to require certificates, not permitting SSH to "fall back" to passwords nor anything else.
Last edited by sundialsvcs; 07-27-2017 at 08:41 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.