ubuntu下通过ssh在两台计算机之间拷贝文件

参考:Linux 远程连接之 SSH 新手指南 - 知乎 (zhihu.com)

1、查看是否安装ssh客户端

(ubuntu下一般默认都安装了)

bash 复制代码
file /etc/ssh/ssh_config

有回复则表示安装了,否则会回复"No such file or directory"

2、查看是否安装ssh服务器
bash 复制代码
file /etc/ssh/sshd_config

有回复则表示安装了,否则会回复"No such file or directory"

3、根据情况安装客户端和服务器
bash 复制代码
// 安装客户端
sudo dnf install openssh-clients

// 安装服务器
sudo dnf install openssh-server
4、查看客户端、服务器是否开启
bash 复制代码
sudo systemctl is-enabled ssh

sudo systemctl is-enabled sshd
5、重启客户端、服务器

(如果没有开启的话)

bash 复制代码
sudo systemctl restart ssh

sudo systemctl restart sshd
6、拷贝文件
1)把当前目录下的1.txt文件拷贝到远程计算机

(计算机用户名为sz,ip地址为10.33.23.93,拷贝到位置/home/share文件夹下)

bash 复制代码
scp  1.txt sz@10.33.23.93:/home/share
2)从远程计算机拷贝文件到当前目录下

(计算机用户名为sz,ip地址为10.33.23.93,拷贝/home/share文件夹下的1.txt到当前目录下)

bash 复制代码
scp sz@10.33.23.93:/home/share/1.txt . 
相关推荐
REDcker6 分钟前
Linux 文件描述符与 Socket 选项操作详解
linux·运维·网络
蒹葭玉树20 分钟前
【C++上岸】C++常见面试题目--操作系统篇(第二十八期)
linux·c++·面试
2501_9277730731 分钟前
imx6驱动
linux·运维·服务器
hy____1231 小时前
Linux_进程间通信
linux·运维·服务器
郭涤生1 小时前
C++的函数是否可以做到完全覆盖Linux和windows的跨平台
linux·c++·windows
德育处主任Pro1 小时前
『NAS』用SSH的方式连上NAS
运维·ssh
南宫码农2 小时前
神马影视8.5版本如意伪静态+视频教程
linux·运维·centos
坐怀不乱杯魂2 小时前
Linux网络 - 网络层
linux·服务器·网络
j_xxx404_2 小时前
Linux:命令行参数与环境变量
linux·运维·服务器
j_xxx404_2 小时前
Linux:进程虚拟地址空间|虚拟内存管理
linux·运维·服务器