linux中ssh远程登陆

server端:

root@server /\]# hostnamectl set-hostname server.example.com \[root@server \~\]# ip a 1: lo: \ mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: \ mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:b1:c7:29 brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 172.25.254.100/24 brd 172.25.254.255 scope global noprefixroute ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:feb1:c729/64 scope link noprefixroute valid_lft forever preferred_lft forever \[root@server \~\]# useradd timinglee \[root@server \~\]# echo 123456 \| passwd --stdin timinglee 更改用户 timinglee 的密码 。 passwd:所有的身份验证令牌已经成功更新。 \[root@server \~\]# systemctl stop firewalld \[root@server \~\]# systemctl disable firewalld 确保只有root用户和timinglee用户可以被登录: \[root@server \~\]# vim /etc/ssh/sshd_config 修改允许登录的账户 #LoginGraceTime 2m PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 AllowUsers timinglee root cilent端: \[root@client /\]# hostnamectl set-hostname client.example.com \[root@client \~\]# ip a 1: lo: \ mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: \ mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:50:6d:df brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 172.25.254.200/24 brd 172.25.254.255 scope global noprefixroute ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe50:6ddf/64 scope link noprefixroute valid_lft forever preferred_lft forever 制作cilent端的公私钥对: \[root@client \~\]# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/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:EYGqkroNQD+sKOWkwA+S1/GomvnldO/19a4nlZq53fg root@client.example.com The key's randomart image is: +---\[RSA 3072\]----+ \| .o. \| \| . . \| \| . .. . \| \|o.o..+ . \| \|=++=o . S .\| \|B\*=.. ..\| \|\*oo.o . . =. \| \|o\* + . . . . =ooo\| \|=oo . .o ..+BE\| +----\[SHA256\]-----+ 将公钥上传至server端: \[root@client \~\]# ssh-copy-id root@172.25.254.100 /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@172.25.254.100's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@172.25.254.100'" and check to make sure that only the key(s) you wanted were added. 实现cilent端的免密登录: \[root@client \~\]# ssh -l root 172.25.254.100 Activate the web console with: systemctl enable --now cockpit.socket Register this system with Red Hat Insights: insights-client --register Create an account or view all your systems at https://red.ht/insights-dashboard Last login: Sat Apr 20 18:19:24 2024 from 172.25.254.200

相关推荐
七七七七071 小时前
【计算机网络】深入理解ARP协议:工作原理、报文格式与安全防护
linux·服务器·网络·计算机网络·安全
qq_5470261792 小时前
Flowable 工作流引擎
java·服务器·前端
奋斗的蛋黄3 小时前
网络卡顿运维排查方案:从客户端到服务器的全链路处理
运维·服务器·网络
wanhengidc4 小时前
云手机搬砖 尤弥尔传奇自动化操作
运维·服务器·arm开发·安全·智能手机·自动化
图图图图爱睡觉4 小时前
主机跟虚拟机ip一直Ping不通,并且虚拟机使用ifconfig命令时,ens33没有ipv4地址,只有ipv6地址
服务器·网络·tcp/ip
deephub4 小时前
FastMCP 入门:用 Python 快速搭建 MCP 服务器接入 LLM
服务器·人工智能·python·大语言模型·mcp
lhxcc_fly5 小时前
Linux网络--8、NAT,代理,网络穿透
linux·服务器·网络·nat
摇滚侠5 小时前
Spring Boot3零基础教程,Spring Boot 应用打包成 exe 可执行文件,笔记91 笔记92 笔记93
linux·spring boot·笔记
wow_DG5 小时前
【运维✨】云服务器公网 IP 迷雾:为什么本机看不到那个地址?
运维·服务器·tcp/ip
yuanManGan5 小时前
走进Linux的世界:初识操作系统(Operator System)
android·linux·运维