其他分享
首页 > 其他分享> > sentos7 ssh远程连接配置

sentos7 ssh远程连接配置

作者:互联网

sentos7 连接配置

安装sentos7

自行安装sentos7 建议使用virtualBox创建

服务端安装openssh-server

# 检查是否已经安装openssh-server
[vagrant@localhost ~]$ yum list installed|grep openssh
openssh.x86_64                       7.4p1-21.el7              @base
openssh-clients.x86_64               7.4p1-21.el7              @base
openssh-server.x86_64

如果不存在需要安装

[vagrant@localhost ~]$ sudo yum install openssh-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.cn99.com
Package openssh-server-7.4p1-21.el7.x86_64 already installed and latest version
Nothing to do
# 提示已经安装了,啥也不干

配置sshd_config

修改配置文件
Port 22
ListenAddress 0.0.0.0
ListenAddress ::
PermitRootLogin yes
PasswordAuthentication yes

[vagrant@localhost ~]$ cd /etc/ssh
[vagrant@localhost ssh]$ ll
total 604
-rw-r--r--. 1 root root     581843 Aug  9  2019 moduli
-rw-r--r--. 1 root root       2276 Aug  9  2019 ssh_config
-rw-------. 1 root root       3916 Jul 14 15:45 sshd_config
[vagrant@localhost ssh]$ vi  ssh_config
# 自行打开配置即可

开启服务

[vagrant@localhost ssh]$  sudo service sshd start

netstat -an | grep 22 检查 22 号端口是否开启监听

[vagrant@localhost ssh]$ netstat -an|grep 22
-bash: netstat: command not found

此时需要安装网络工具

sudo yum install -y net-tools

重新检查22端口

[vagrant@localhost ssh]$ netstat -an | grep 22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 10.0.2.15:38772         183.60.138.229:80       TIME_WAIT
tcp        0      0 10.0.2.15:22            10.0.2.2:53359          ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN

设置开机重启
systemctl enable sshd.service

标签:sentos7,22,openssh,vagrant,ssh,root,远程,localhost
来源: https://blog.csdn.net/weixin_43704834/article/details/118853821