• Linux和远程系统同步文件(未完成)


    实验环境:

    本地主机:192.168.0.1
    
    远程主机:192.168.0.101

    1. 使用 scp,把/root/tardir1/achieve2.tar.gz复制到远程主机的root用户的home目录下

    [root@desktop1 ~]# scp ~/tardir1/achieve2.tar.gz 192.168.0.101:/root
    The authenticity of host '192.168.0.101 (192.168.0.101)' can't be established.
    ECDSA key fingerprint is 57:24:51:ec:a4:74:eb:4d:06:cd:2f:93:d8:b1:5e:43.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '192.168.0.101' (ECDSA) to the list of known hosts.
    root@192.168.0.101's password:
    achieve2.tar.gz 100% 35KB 35.4KB/s 00:00
    [root@desktop1 ~]#

    2. 使用 root 用户 ssh 到 远程主机 上,确认 root 的 home 目录下是否有前面复制过来的文件

    [root@desktop1 ~]# ssh root@192.168.0.101
    root@192.168.0.101's password: 
    Last login: Thu Nov  3 10:22:14 2016 from 192.168.0.1
    [root@server101 ~]# ls
    achieve2.tar.gz  anaconda-ks.cfg  rht-ks-post.log

    3. 在 root的home 目录下,创建一个目录 dir1

    [root@server101 ~]# mkdir dir1
    [root@server101 ~]# 

    4. 在 本地主机 上,使用一条 scp 命令,把 本地主机的 的/root/ tardir1/achieve2.tar.gz 和/root/tardir1/achieve1.tar 这 2 个文件一次性复制到 远程主机的/root/dir1 下 

    [root@desktop1 ~]# scp ~/tardir1/achieve2.tar.gz ~/tardir1/achieve1.tar 192.168.0.101:/root/dir1
    root@192.168.0.101's password: 
    achieve2.tar.gz                        100%   35KB  35.4KB/s   00:00    
    achieve1.tar                           100%  170KB 170.0KB/s   00:00    
    [root@desktop1 ~]# 

    5. 使用本地主机的root用户,再把上一个步骤的2个文件复制到远程主机的student用 户的 home 目录下

    [root@desktop1 ~]# scp ~/tardir1/achieve2.tar.gz ~/tardir1/achieve1.tar 192.168.0.101:/home/student/
    root@192.168.0.101's password: 
    achieve2.tar.gz                        100%   35KB  35.4KB/s   00:00    
    achieve1.tar                           100%  170KB 170.0KB/s   00:00    
    [root@desktop1 ~]# 

    6. 在本地主机上切换至student用户,尝试用以下命令把 achieve1.tar 复制到 远程主机 的 root 用户主目录下,提示失败

    原因:本地主机的student用户可以连接到远程主机,但是因为student没有权限在远程主机的/root用户里进行操作,所以提示失败。 

    [student@desktop1 ~]$ ls
    achieve1.tar  at.txt  cron.txt  etc  mycrontab.cfg
    [student@desktop1 ~]$ scp achieve1.tar 192.168.0.101:/root
    The authenticity of host '192.168.0.101 (192.168.0.101)' can't be established.
    ECDSA key fingerprint is 57:24:51:ec:a4:74:eb:4d:06:cd:2f:93:d8:b1:5e:43.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '192.168.0.101' (ECDSA) to the list of known hosts.
    student@192.168.0.101's password: 
    Permission denied, please try again.
    student@192.168.0.101's password: 

    7. 用 scp 命令,把 achieve1.tar 复制到 system30 的 root 用户主目录下,注意,此步登陆远程主机使用的是root用户本身

    [student@desktop1 ~]$ scp achieve1.tar root@192.168.0.101:/root
    root@192.168.0.101's password: 
    achieve1.tar                           100%  170KB 170.0KB/s   00:00    
    [student@desktop1 ~]$ 

    8. 

  • 相关阅读:
    从原理上理解NodeJS的适用场景
    core 基本操作
    SQL Server 触发器
    Centos 7 Apache .netcore 做转发
    Windows Server 使用 WAMP 并配置 Https
    centos7 apache php git pull
    Visual StudioTools for Unity 使用技巧2
    如何实现Windows Phone代码与Unity相互通信(直接调用)
    关于NGUI与原生2D混用相互遮盖的问题心得
    关于NGUI制作图集在低内存设备上的注意事项
  • 原文地址:https://www.cnblogs.com/tdcqma/p/6023810.html
Copyright © 2020-2023  润新知