how to use scp without password:
1) run this command to generate public key ssh-keygen -t rsa In response you'll see: "Generating public/private rsa key pair" "Enter file in which to save the key ... " Just hit enter to accept this. In response you'll see: "Enter passphrase (empty for no passphrase):" You don't need a passphrase, so just hit enter twice. In response you'll see: "Your identification has been saved in ... " "Your public key has been saved in ... " Note the name and location of the public key just generated (it will always end in .pub).
2) Copy the public key just generated to any server:/root/.ssh/authorized_keys
3) now you run "sudo scp filename user@serverName:/path/" Wow !!! It copied with no password!!
Note:须在本机上面生成钥匙对,然后把公匙发送到远程计算机,这样使用SCP的时候就不用输入远程计算机的密码了.
Step by step:
1. ssh-keygen �t rsa
2. Hit 'enter'
可以追加多个公匙:
[root@web07p .ssh]# ls -l
total 12
-rw-r--r-- 1 root root 220 Jan 8 01:25 250authorized_keys
-rw-r--r-- 1 root root 220 Jan 8 01:24 authorized_keys
-rw-r--r-- 1 root root 2906 Dec 27 18:35 known_hosts
[root@web07p .ssh]# ls
25023.pub 250authorized_keys authorized_keys known_hosts
[root@web07p .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAtupCHjuGftXqAUmIWNs4Dq9Tww8sGni5mA19XeUnZ2QOionV2owpGHvYbTUc/+jwgMVyzBBZXXv0m1mI+Kl0nLV9kWg1VqnF+5X7OqCoykNxXZPAVdaTO7xAqC/nmiAgmqK8vhVsOk2aM96s8b7a40Deex/Q7+yE8qrNXX9+FCE= root@db03p
[root@web07p .ssh]# cat 25023.pub >>authorized_keys
[root@web07p .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAtupCHjuGftXqAUmIWNs4Dq9Tww8sGni5mA19XeUnZ2QOionV2owpGHvYbTUc/+jwgMVyzBBZXXv0m1mI+Kl0nLV9kWg1VqnF+5X7OqCoykNxXZPAVdaTO7xAqC/nmiAgmqK8vhVsOk2aM96s8b7a40Deex/Q7+yE8qrNXX9+FCE= root@db03p
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAuiWname5RnDVRbyRg2mouwqTJs6TRF82GCf5k3GblxYYXq7WTp3MRN+v1dI9IAHUKM3bGSXAnIIHsJ04ZSBz+jvdTLfn8eE7K9ebZvfGWRNLwZMay2C3MUaa7DCpqnamMGy1nIw9w1ir/gfsQk/wxy7REqoHiU9hShGp0Qac/h8= root@web08
[root@web07p .ssh]#
没有评论:
发表评论