Linux命令(125)之scp

简介: Linux命令(125)之scp

linux命令之scp

1.scp介绍
linux命令scp用于在两个主机之间安全的复制文件和目录

2.scp用法
scp [参数]

scp常用参数
参数 说明
-P 指定远程主机的端口
-p 复制文件时,保留原始文件的属性(E
[root@rhel77 ~]# scp 192.168.10.249.txt root@192.168.10.244:/root/
root@192.168.10.244's password:
192.168.10.249.txt 100% 60 51.7KB/s 00:00
[root@rhel77 ~]#
.g:修改次数、访问次数和模式、创建时间等)
-r 递归复制整个目录
-q 静默传输模式
-v 输出详细信息
3.实例
3.1.复制本地文件至远程主机
命令:

scp 192.168.10.249.txt root@192.168.10.244:/root/

[root@rhel77 ~]# scp 192.168.10.249.txt root@192.168.10.244:/root/
root@192.168.10.244's password:
192.168.10.249.txt 100% 60 51.7KB/s 00:00
[root@rhel77 ~]#
[root@logstash ~]# ls -l 192.168.10.249.txt
-rw-r--r-- 1 root root 60 Nov 17 08:44 192.168.10.249.txt
[root@logstash ~]# cat 192.168.10.249.txt
192.168.10.249
192.168.10.249
192.168.10.249
192.168.10.249
[root@logstash ~]#
3.2.复制目录至远程主机
命令:

scp -prqv /root/ztj.bak/ root@192.168.10.244:/root/

[root@rhel77 ~]# scp -prqv /root/ztj.bak/ root@192.168.10.244:/root/
Executing: program /usr/bin/ssh host 192.168.10.244, user root, command scp -v -r -p -t /root/
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for
debug1: Connecting to 192.168.10.244 [192.168.10.244] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH
compat 0x04000000
debug1: Authenticating to 192.168.10.244:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: none
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:EADmS0F6cqxJ00yk8pc9FgPizA/kfgBDdJTOnzrLX6Q
debug1: Host '192.168.10.244' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:2
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password
root@192.168.10.244's password:
debug1: Authentication succeeded (password).
Authenticated to 192.168.10.244 ([192.168.10.244]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: scp -v -r -p -t /root/
File mtime 1699619416 atime 1700181824
Sending file timestamps: T1699619416 0 1700181824 0
Sink: T1699619416 0 1700181824 0
Entering directory: D0777 0 ztj.bak
Sink: D0777 0 ztj.bak
File mtime 1699407457 atime 1699619299
Sending file timestamps: T1699407457 0 1699619299 0
Sink: T1699407457 0 1699619299 0
Sending file modes: C0644 11 ztj-2.txt
Sink: C0644 11 ztj-2.txt
File mtime 1699407510 atime 1699619297
Sending file timestamps: T1699407510 0 1699619297 0
Sink: T1699407510 0 1699619297 0
Sending file modes: C0644 10 ztj-1.txt
Sink: C0644 10 ztj-1.txt
File mtime 1699619079 atime 1699619100
Sending file timestamps: T1699619079 0 1699619100 0
Sink: T1699619079 0 1699619100 0
Sending file modes: C0755 26 test.sh
Sink: C0755 26 test.sh
Sink: E
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2836, received 3168 bytes, in 0.1 seconds
Bytes per second: sent 36610.1, received 40895.9
debug1: Exit status 0
[root@rhel77 ~]#

[root@logstash ~]# ls -ld ztj.bak/
drwxrwxrwx 2 root root 55 Nov 10 20:30 ztj.bak/
[root@logstash ~]# cd ztj.bak/
[root@logstash ztj.bak]# ll
total 12
-rwxr-xr-x 1 root root 26 Nov 10 20:24 test.sh
-rw-r--r-- 1 root root 10 Nov 8 09:38 ztj-1.txt
-rw-r--r-- 1 root root 11 Nov 8 09:37 ztj-2.txt

————————————————
版权声明:本文为CSDN博主「小黑要上天」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/z19861216/article/details/134454496

目录
相关文章
|
27天前
|
Linux
linux命令详细说明以及案例
本文介绍了常用的 Linux 命令及其详细说明和示例,包括:`ls`(列出目录内容)、`cd`(更改目录)、`rm` 和 `mv`(删除与移动文件)、`grep`(搜索文本)、`cat`(显示文件内容)以及 `chmod`(更改文件权限)。每个命令均配有功能描述、选项说明及实际案例,帮助用户更好地掌握 Linux 命令的使用方法。
142 56
|
12天前
|
Linux 定位技术
Linux系统中的cd命令:目录切换技巧
踏过千山,越过万水,人生就是一场不断前行的旅程,总充满了未知与挑战。然而,“cd”命令如同你的旅伴,会带你穿梭在如棋盘一般的文件系统中,探索每一处未知。希望你能从“cd”命令中找到乐趣,像是掌控了一种络新妙的魔法,去向未知进发,开始你的探索之旅。
86 24
|
4天前
|
Linux
Linux命令的基本格式解析
总的来说,Linux命令的基本格式就像一个食谱,它可以指导你如何使用你的计算机。通过学习和实践,你可以成为一个真正的“计算机厨师”,创造出各种“美味”的命令。
41 15
|
15天前
|
安全 Shell Linux
Linux系统之su命令的基本使用
Linux系统之su命令的基本使用
65 2
Linux系统之su命令的基本使用
|
17天前
|
监控 数据可视化 Java
调试技巧 - 用Linux命令排查Java问题
总的来说,使用Linux命令来排查Java问题,需要一定的实践经验和理论知识。然而,只要我们愿意花时间深入了解这些工具,我们就能够熟练地使用它们来分析和解决问题。此外,这些工具只是帮助我们定位问题,真正解决问题需要我们对Java和JVM有深入的理解,并能够读懂和分析代码。
57 13
|
30天前
|
监控 Linux
Linux基础:文件和目录类命令分析。
总的来说,这些基础命令,像是Linux中藏匿的小矮人,每一次我们使用他们,他们就把我们的指令准确的传递给Linux,让我们的指令变为现实。所以,现在就开始你的Linux之旅,挥动你的命令之剑,探索这个充满神秘而又奇妙的世界吧!
71 19
|
1月前
|
Linux
Linux 常用文件查看命令
`cat` 命令用于连接文件并打印到标准输出,适用于快速查看和合并文本文件内容。常用示例包括:`cat file1.txt` 查看单个文件,`cat file1.txt file2.txt` 合并多个文件,`cat > filename` 创建新文件,`cat >> filename` 追加内容。`more` 和 `less` 命令用于分页查看文件,`tail` 命令则用于查看文件末尾内容,支持实时追踪日志更新,如 `tail -f file.log`。
66 5
Linux 常用文件查看命令
|
27天前
|
Linux
linux常用命令详细说明以及案例
本文介绍了Linux中几个常用的命令及其用法,包括:`ls`(列出目录内容)、`cd`(切换目录)、`mkdir`(创建目录)、`rm -p`(删除目录及内容)和`mv`(移动或重命名文件/目录)。每个命令都配有详细说明、语法格式、常见选项及实用案例,帮助用户更好地理解和使用这些基础命令。内容源自[linux常用命令详细说明以及案例](https://linux.ciilii.com/show/news-285.html)。
|
2月前
|
Linux
Linux系统之whereis命令的基本使用
Linux系统之whereis命令的基本使用
128 24
Linux系统之whereis命令的基本使用
|
1月前
|
Linux
Linux od命令
本文详细介绍了Linux中的 `od`命令,包括其基本语法、常用选项和示例。通过这些内容,你可以灵活地使用 `od`命令查看文件内容,提高分析和调试效率。确保理解每一个选项和示例的实现细节,应用到实际工作中时能有效地处理各种文件查看需求。
73 19
下一篇
oss创建bucket