linux远程控制

linux远程控制

挂载光驱:mount /dev/cdrom /mnt

ssh服务端:

yum -y install openssh openssh-clients

重启ssh服务,设置下次启动生效

systemctl restart sshd

systemctl enable sshd

ssh

22

连接协议、用户认证协议、传输协议

对称加密

基于密码认证

基于密钥认证

版本协商阶段

密钥和算法的协商

认证

会话请求

交互会话

sftp

put 先写客户端文件 服务端目录

get 服务端文件 客户端目录

scp 客户端文件 用户@服务器ip:服务器目录

scp 用户@服务器ip:服务器文件 客户端目录

ssh 用户名@服务器的IP

复制代码
[root@ws ~]# ssh root@192.168.110.20
root@192.168.110.20's password: 
Last login: Mon Jul 28 18:16:08 2025 from 192.168.110.10
[root@ws2 ~]# 

能不能ssh远程控制

复制代码
[root@ws ~]# cd /etc/ssh/
[root@ws ssh]# ls
moduli       ssh_host_ecdsa_key      ssh_host_ed25519_key.pub
ssh_config 服务端  ssh_host_ecdsa_key.pub  ssh_host_rsa_key
sshd_config 客户端 ssh_host_ed25519_key    ssh_host_rsa_key.pub
[root@ws ssh]# vim sshd_config 

基于密钥验证

在客户端:

生成公钥和私钥

ssh-keygen

复制代码
[root@ws ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 	//密钥默认在/root/.ssh/id_rsa
Enter passphrase (empty for no passphrase):   // 可以设置密码为空 为空登录不需要密码
Enter same passphrase again: 	//确认密码
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:AUxTGMufgUx1uxfGrGo6PTQEcCnfFcIhvL/TML9m5dE root@ws.example.com
The key's randomart image is:
+---[RSA 2048]----+
|    .=OB=.o.     |
|    .=**.o.+     |
|     o=+o.. =    |
|      o.o+ + .   |
|       oS o ..   |
|        *. .o E  |
|       ooB o .   |
|      .o= = .    |
|      .. =..     |
+----[SHA256]-----+
[root@ws ~]# cd .ssh/
[root@ws .ssh]# ls
id_rsa 私钥   id_rsa.pub 公钥  known_hosts

上传公钥到服务器端

ssh-cpoy-id -i ~/.ssh/id_rsa.pub root@192.168.110.20

复制代码
[root@ws .ssh]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.110.20
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.110.20's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@192.168.110.20'"
and check to make sure that only the key(s) you wanted were added.
服务段验证有没有公钥
[root@ws2 ~]# ls -a
.                .bash_profile  .dbus                 .ssh      视频  桌面
..               .bashrc        .esd_auth             .tcshrc   图片
anaconda-ks.cfg  .cache         .ICEauthority         .viminfo  文档
.bash_history    .config        initial-setup-ks.cfg  公共      下载
.bash_logout     .cshrc         .local                模板      音乐
[root@ws2 ~]# cd .ssh/
[root@ws2 .ssh]# ls
authorized_keys

[root@ws ~]# ssh root@192.168.110.20
Last login: Mon Jul 28 18:19:26 2025 from 192.168.110.10
[root@ws2 ~]# 
ws1登录到ws2无需密码
必须是用户与用户之间	

客户端:

ssh root@192.168.110.20 ---不能上传、下载

sftp root@192.168.110.20 --可以上传、下载---put上传、get下载

scp /tmp/aa root@192.168.110.20:/var 上传

复制代码
[root@ws1 ~]# sftp root@192.168.110.20 
The authenticity of host '192.168.110.20 (192.168.110.20)' can't be established.
ECDSA key fingerprint is SHA256:ns26rOoUG181jGScbaJaHhHwWsVuzNSM8JHsnTQoRgg.
ECDSA key fingerprint is MD5:69:c8:73:82:90:f8:0b:71:cb:ce:ae:22:c1:0b:86:ca.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.110.20' (ECDSA) to the list of known hosts.
root@192.168.110.20's password: 
Connected to 192.168.110.20.
sftp> 
sftp> put a /tmp/
Uploading a to /tmp/a
a                                             100%    0     0.0KB/s   00:00  
[root@ws2 tmp]# ls
a
[root@ws2 tmp]# 
已经把ws1上的a文件上传到ws2上的/tmp

scp root@192.168.110.20:/tmp/cc /var 下载

复制代码
先在ws2上创建aa文件
[root@ws2 tmp]# touch aa
sftp> get /tmp/aa .  //.代表当前目录
Fetching /tmp/aa to ./aa
sftp> exit
[root@ws1 ~]# ls
a   anaconda-ks.cfg  initial-setup-ks.cfg  公共  文档  模板  音乐
aa  b                下载                  图片  桌面  视频

无需远程登录就可以传文件和下载文件 (仅限于linux与Linux)

复制代码
[root@ws ~]# scp file1 root@192.168.110.20:/tmp/
file1                                         100%    0     0.0KB/s   00:00
[root@ws2 tmp]# ls
file1

下载文件
[root@ws2 tmp]# touch file2
[root@ws ~]# scp root@192.168.110.20:/tmp/file2 .
file2                                         100%    0     0.0KB/s   00:00 
[root@ws ~]# ls
anaconda-ks.cfg  file2                 下载  图片  桌面  视频
相关推荐
Sylvia@8881 分钟前
19.管理基本存储
linux·运维·1024程序员节
文火冰糖的硅基工坊2 分钟前
[嵌入式系统-150]:智能机器人(具身智能)内部的嵌入式系统以及各自的功能、硬件架构、操作系统、软件架构
android·linux·算法·ubuntu·机器人·硬件架构
susu108301891120 分钟前
ubuntu 查看文件夹占了多大
linux·运维·ubuntu
小涵31 分钟前
第 01 天:Linux 是什么?内核、发行版及其生态系统
linux·运维·devops·1024程序员节·sre
hhhh明37 分钟前
Google Drive 超大文件下载到服务器
服务器·网络·google drive
小小的木头人1 小时前
APT 安装方式(适合生产环境)Zabbix 6.4 LTS
运维·zabbix
IvanCodes1 小时前
十六、Linux网络配置
linux·运维·网络
j_xxx404_1 小时前
Linux:权限(完结)|权限管理|修改权限chmod chown charp|文件类型|拓展
linux·运维·服务器
板鸭〈小号〉1 小时前
应用层自定义协议与序列化
运维·服务器·网络·1024程序员节
wanhengidc1 小时前
传奇手游可以使用云手机挂机搬砖吗
服务器·arm开发·智能手机·玩游戏·1024程序员节