linux互相登陆

linux中的用户登陆时基于sshd服务的,安装openssh

[root@localhost ~]# yum install openssh-server openssh openssh-clients
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
软件包 openssh-server-7.4p1-16.el7.x86_64 已安装并且是最新版本
软件包 openssh-7.4p1-16.el7.x86_64 已安装并且是最新版本
软件包 openssh-clients-7.4p1-16.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]# systemctl restart sshd
[root@localhost ~]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1361/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1056/master         
tcp6       0      0 :::22                   :::*                    LISTEN      1361/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1056/master

使用ssh命令登陆(ssh username@ip [-p port]]):

注意需要关闭linux下的防火墙

这样登陆需要密码,我们可以使用密钥登陆:

最后更新于

这有帮助吗?