Secure Copy Protocol or SCP

Secure Copy Protocol or SCP

Secure copy protocol or SCP is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol. SCP commonly refers to both the Secure Copy Protocol and the program itself.

Some SSH implementations provide the scp2 program, which uses the SFTP protocol instead of SCP, but provides the very same command line interface as scp. scp is then typically a symbolic link to scp2.

Typically, a syntax of scp program is like the syntax of cp (copy).

Copying file to host:

scp SourceFile user_name@host_ip:directory/TargetFile

Copying file from host:

scp user_name@host_ip:directory/SourceFile TargetFile
scp -r user_name@host_ip:directory/SourceFolder TargetFolder

Note that if the remote host uses a port other than the default of 22, it can be specified in the command. For example, copying a file from host:

scp -P 2222 user_name@host_ip:directory/SourceFile TargetFile

As the Secure Copy Protocol implements file transfers only, GUI SCP clients are rare, as implementing it requires additional functionality (directory listing at least). For example, WinSCP defaults to the SFTP protocol. Even when operating in SCP mode, clients like WinSCP are typically not pure SCP clients, as they must use other means to implement the additional functionality (like the ls command). This in turn brings platform-dependency problems.

Ubuntu 默认并没有安装 ssh 服务程序 (openssh-server),默认安装了 ssh 客户程序 (openssh-client)。

  1. ssh localhost

    strong@foreverstrong:~$ ssh localhost
    ssh: connect to host localhost port 22: Connection refused

  2. 查看 ssh 服务是否启动 / 运行

    strong@foreverstrong:~$ ps -e | grep ssh
    strong@foreverstrong:~$
    strong@foreverstrong:~$ sudo ps -e | grep ssh
    strong@foreverstrong:~$
    strong@foreverstrong:~$ sudo service ssh start
    Failed to start ssh.service: Unit ssh.service not found.
    strong@foreverstrong:~$

  3. 安装 ssh 服务

    strong@foreverstrong:~$ sudo apt-get install openssh-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
    ...
    strong@foreverstrong:~$

  4. 启动

    strong@foreverstrong:~$ sudo /etc/init.d/ssh start
    [sudo] password for strong:
    [ ok ] Starting ssh (via systemctl): ssh.service.
    strong@foreverstrong:~$

  5. 停止

    sudo /etc/init.d/ssh stop

ssh 默认的端口是 22,可以修改配置文件更改端口,然后重启 ssh 服务即可。(配置文件 /etc/ssh/sshd_config)

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/

相关推荐
安全二次方security²1 个月前
ARM功耗管理框架之SCP
scp·power manage·系统控制处理器·arm功耗管理·功耗管理精讲与实战·功耗管理框架·mhu
骑着蜗牛追汽车1 个月前
scp:Linux系统本地与远程文件传输命令
linux·服务器·网络·scp
SummerGao.1 个月前
Linux 使用scp指令远程连接复制文件或文件夹
linux·scp
风浅月明3 个月前
[iOS]协议中如何添加属性?
ios·protocol
Yongqiang Cheng3 个月前
Secure Copy Protocol or SCP - 安全拷贝协议
scp·protocol·secure copy·安全拷贝协议
worxfr6 个月前
Linux文件传输工具 scp 和 rsync 使用详解和优势对比
linux·服务器·网络·scp·工具·rsync·文件传输
安全二次方security²7 个月前
电源控制系统架构(PCSA)之系统控制处理器(SCP)协调
scp·arm·低功耗·电源控制系统架构·pcsa·power manage·系统控制处理器
安全二次方security²7 个月前
电源控制系统架构(PCSA)之系统控制处理器组件
scp·arm·低功耗·电源控制系统架构·pcsa·power manage·系统控制处理器
rexinx10 个月前
1.0零基础尝试DCM通讯(c-store)
网络协议·scp·dicom配置·dicom·scu·通讯