using ssh keys with scp and ssh

不羁岁月 提交于 2020-01-12 13:02:31

问题


I am trying to copy few files to a target system using scp and then login to the system and install those files. I used scp and ssh commands here with ssh keys for passwordless authentication.

The ssh key was created on the source system as below. Is this the correct and secured way of creating an ssh key?

~]# ssh-keygen -t rsa -N "" -f ~/.ssh/mytest.key

The key was copied from the source to target system with executing below command.

~]# ssh-copy-id -i ~/.ssh/mytest.key 

Now, the SSH login works fine without prompting for a password, however the scp is still not working.. it still prompts for a password. Should I specify the key path when using scp? If so how do I specify the keypath along with scp command?

Here is the ssh command used

~]# ssh -i ~/.ssh/mytest.key root@192.168.1.1

回答1:


Assume your case for scp from 192.168.1.1 try below command.

scp -i ~/.ssh/mytest.key root@192.168.1.1:/<filepath on host>  <path on client>

make sure the key file should have permission 600 or 400.



来源:https://stackoverflow.com/questions/24116454/using-ssh-keys-with-scp-and-ssh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!