Linux ssh服务操作

目录

一、SSH远程登录

二、密钥认证登录

三、远程拷贝


一、SSH远程登录

操作之前先关闭防火墙和安全策略selinux(服务器端和客户机)

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# getenforce 0

安装相应的软件:

[root@localhost ~]# yum -y install openssh*

 服务器端(10.0.0.129)

 启动服务并重启:

[root@localhost ~]# systemctl start sshd

查看22号端口:

[root@localhost ~]# lsof -i:22

客户机端(10.0.0.130) 

远程登录管理

[root@localhost ~]# ssh -x [email protected]


二、密钥认证登录

服务器端(10.0.0.129)

生成公钥和私钥

[root@localhost tmp]# ssh-keygen

拷贝公钥给客户机

[root@localhost ~]# ssh-copy-id -i 10.0.0.130

 进行远程登录

[root@localhost ~]# ssh 10.0.0.130
Last login: Thu Oct 21 01:12:55 2021 from 10.0.0.1

三、远程拷贝

服务器端(10.0.0.129)

在/tmp下创建1.txt文件,拷贝到客户端(10.0.0.130)的/tmp下

[root@localhost tmp]# touch 1.txt
[root@localhost tmp]# scp 1.txt 10.0.0.130:/tmp/


客户端(10.0.0.130):

在/tmp下创建he文件

[root@localhost tmp]# touch he

服务器端 (10.0.0.129):

远程获取客户端的he文件

[root@localhost tmp]# scp 10.0.0.130:/tmp/he   /tmp/

你可能感兴趣的:(linux,ssh,运维)