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/

相关推荐
过过过呀Glik11 天前
在 Ubuntu 中安装 C++ 版本的 Protocol Buffers
linux·c++·ubuntu·protocol
坐望云起21 天前
Protocol Buffer
运维·服务器·网络·protocol·buffers
马甲是掉不了一点的<.<1 个月前
本地电脑使用命令行上传文件至远程服务器
linux·scp·cmd·远程文件上传
命里有定数2 个月前
Ubuntu问题 -- 使用scp将本机文件传输至ubuntu服务器中
linux·服务器·ubuntu·scp·文件传输
专业机床数据采集3 个月前
西门子网络程序传输,无需开通网络驱动器直接接入底层,支持各类数控 如发那科、三菱 、新代、海德汉、广数、精雕、马扎克等等
网络·scp·采集·程序传输·机床数据采集·西门子马扎克海德汉发那科·三菱新代凯恩帝牧野广州数控广数
橘色的喵4 个月前
Linux Shell: 使用 Expect 自动化 SCP 和 SSH 连接的 Shell 脚本详解
linux·ssh·scp·expect·远程·自动登录
白80804 个月前
openssh 命令注入 (CVE-2020-15778)
scp·openssh
caz285 个月前
scp命令的使用
scp
安全二次方security²7 个月前
ARM功耗管理框架之SCP
scp·power manage·系统控制处理器·arm功耗管理·功耗管理精讲与实战·功耗管理框架·mhu
骑着蜗牛追汽车8 个月前
scp:Linux系统本地与远程文件传输命令
linux·服务器·网络·scp