linux远程画面同步,linux远程文件同步

1.先准备环境

sudo apt-get install ssh 2.建立凭证

ssh-keygen

//注意,file与passphrase均无需输入

Generating public/private rsa key pair.

Enter file in which to save the key (/home/user1/.ssh/id_rsa):

/home/user1/.ssh/id_rsa already exists.

Overwrite (y/n)?

user1@localhost:~$ ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/home/user1/.ssh/id_rsa):

/home/user1/.ssh/id_rsa already exists.

Overwrite (y/n)? y

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/user1/.ssh/id_rsa.

Your public key has been saved in /home/user1/.ssh/id_rsa.pub.

The key fingerprint is:

ed:89:09:e0:5b:44:d0:78:e3:a2:a2:55:5c:15:43:e2 user1@localhost

The key's randomart image is:

+--[ RSA 2048]----+

|    .+oo=.       |

|    .o=. .       |

|   ..+E.         |

|   .+o.  .       |

|   o..o S .      |

|. o  o . + .     |

|.o  .   o o      |

|.                |

|                 |

+-----------------+

3.上传凭证

scp ~/.ssh/id_rsa.pub user1@ip:/home/user1/.ssh/authorized_keys

若远端报无此目录异常,可先在远端机器执行ssh-keygen命令产生,Copy成功信息:

id_rsa.pub                                    100%  400     0.4KB/s   00:00

4.无密码连接

ssh your-ip

//若出现此信息:

Agent admitted failure to sign using the key.

//执行: ssh-add   ~/.ssh/id_rsa

//连接成功信息,注意命令提示已经切换到远端:

Last login: Sat Oct 25 09:57:29 2014 from 192.16.1.100

[user1@centos ~]$

//设定其文件权限

chmod 600 ~/.ssh/authorized_keys

5.文件同步

rsync -a --delete/opt/data/ user1@192.16.1.100:/opt/data/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值