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
  1. 查看 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:~$
  1. 安装 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:~$
  1. 启动
strong@foreverstrong:~$ sudo /etc/init.d/ssh start
[sudo] password for strong: 
[ ok ] Starting ssh (via systemctl): ssh.service.
strong@foreverstrong:~$
  1. 停止
sudo /etc/init.d/ssh stop

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

References

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值