kali开启远程ssh服务

前言

简单记录一下kali开启远程ssh服务的配置与sshd_config的配置文件选项作用

Here we go

1.配置sshd_config文件

sshd_config文件是位于/etc/ssh/目录下的ssh服务器服务端配置文件,通过修改配置文件改变ssh服务的运行方式。ssh_config文件采用了关键字+值的方式定义,关键字忽略大小写(文件配置不正确可能会导致ssh服务启动失败–这让我折腾了一下
下面为sshd_config文件部分设置翻译

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
#Port 22
## 监听端口号
#AddressFamily any
## 指定 sshd 应当使用哪种地址族。取值范围是:"any"(默认)、"inet"(仅IPv4)、"inet6"(仅IPv6)。
#ListenAddress 0.0.0.0
#ListenAddress ::
## 监听ip与ip段
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
## 登录验证的等待时间
#PermitRootLogin yes
## 是否允许 root用户登入
#StrictModes yes
## StrictModes用来设置ssh在接收登录请求之前是否检查用户根目录和rhosts文件的权限和所有权,建议开启
#MaxAuthTries 6
## 最多登录尝试次数
#MaxSessions 10
## 最大会话数
#PubkeyAuthentication yes
## 是否允许 Public Key
# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
## AuthorizedKeysFile用来设置公钥验证文件的路径,与PubkeyAuthentication配合使用,默认值是".ssh/authorized_keys"。
### 该指令中可以使用下列根据连接时的实际情况进行展开的符号: %% 表示'%'、%h 表示用户的主目录、%u 表示该用户的用户名
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
# PasswordAuthentication yes
## 是否开启密码验证机制
#PermitEmptyPasswords no
# 用来设置是否允许用口令为空的账号登录系统。
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
## 是否显示上次登录信息
#TCPKeepAlive yes
## TCPKeepAlive 是否持续连接,设置yes可以防止死连接
### 一般而言,如果设定这项目的话,那么 SSH Server 会传送 KeepAlive 的讯息给 Client 端,以确保两者的联机正常!
#### 这种消息可以检测到死连接、连接不当关闭、客户端崩溃等异常。在这个情况下,任何一端死掉后, SSH 可以立刻知道,而不会有僵尸程序的发生!
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
## 是否对通信数据进行加密(yes or no),delayed 这是延迟到认证成功之后再对通信数据加密
#ClientAliveInterval 0
## 设置一个以秒记的时长,如果超过这么长时间没有收到客户端的任何数据,sshd将通过安全通道向客户端发送一个"alive"消息,并等候应答。默认值 0表示不发送"alive"消息。这个选项仅对SSH-2有效。
#ClientAliveCountMax 3
#UseDNS no
## UseDNS是否使用dns反向解析
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
# override default of no subsystems
Subsystem sftp /usr/lib/openssh/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
## 设置是否允许允许tcp端口转发,保护其他的tcp连接
# PermitTTY no
# ForceCommand cvs server

配置远程ssh登录需要更改两个关键字的值,分别是PermitRootLogin yesPasswordAuthentication yes

2.重启ssh服务

/etc/init.d/ssh restart

3.添加启动ssh自动启动

update-rc.d ssh enable

后记

撸起袖子加油干

本文标题:kali开启远程ssh服务

文章作者:MelonRindCat

发布时间:2018年02月26日 - 22:02

最后更新:2018年03月16日 - 13:03

原始链接:http://melonrind.top/2018/85eb82d1/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。