一.SCP---主机之间拷贝文件
1.把当前的文件.bash_profile,拷贝到远程主机172.23.204.90,用户sunxiangwei,的根目录下(本机――>远程),
scp .bash_profile
2.下载远程机器上的档案到本地来(远程――>本机)
scp /etc
将/etc/test1.txt,拷贝到本机的/etc目录下。
3.建立信任,不用输入密码了
两台LINUX主机之间要互传文件时可使用SCP命令来实现,建立信任关系之后可不输入密码。
把你的本地主机用户的ssh公匙文件复制到远程主机用户的~/.ssh/authorized_keys文件中
假设本地主机linux100,远程主机linux200
一,在linux100主机里的用户
运行
#ssh-keygen -t rsa
结果如下
QUOTE:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/.username/ssh/id_rsa):#回车
Enter passphrase (empty for no passphrase):#回车
Enter same passphrase again:#回车
Your identification has been saved in /home/.username /.ssh/id_rsa.
Your public key has been saved in /home/.username /.ssh/id_rsa.pub.
The key fingerprint is:
38:25:c1:4d:5d:d3:89:bb:46:67:bf:52:af:c3:17:0c username@localhost
Generating RSA keys:
Key generation complete.
会在用户目录~/.ssh/产生两个文件,id_rsa,id_rsa.pub
二,把linux100主机上的id_rsa.pub文件拷贝到linux200主机的用户test主目录下的.ssh目录下,并且改名为authorized_keys
即:
~test/.ssh/authorized_keys
这样在linux100主机上使用scp命令复制文件到linux200上将不提示输入密码了,直接复制了。
反之亦然!
阅读(2427) | 评论(0) | 转发(0) |