作者ruthertw (督人无数就是我)
看板Linux
标题[问题] Ubuntu突然scp可以登入但ssh不能登入
时间Mon Mar 1 16:49:35 2021
有一阵子没有登入实验室主机(Ubuntu),
今天使用terminal登入时,
发现无法登入.
尝试登入太多次後,
有时会出现
ssh: connect to host XX port 22: Connection timed out
有时会出现
ERROR: ssh: connect to host XX port 22: Connection refused
有时会出现
Permission denied (publickey,password).
我知道登入太多次会直接被ban,
然後Connection refused,
要隔一段时间才能尝试登入.
查过(publickey,password)的问题,
有可能没有验证成功,
所以也试了ssh-copy-id.
发现应该是被网管(学弟)改了帐号权限.
问了学弟,
他说他不懂Ubuntu,
只是被叫来做网管,
如果有被他改到什麽地方,
他不知道也不清楚.
他说也没有root密码,
su -他没用过,
他只会用sudo xxx这样.
我试着用scp,
结果可以登入,
改用winscp,
也可以登入,
但是就是不能使用terminal模式登入.
请问Ubuntu突然变成scp可以登入但ssh不能登入,
是甚麽地方被改到了?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 223.137.160.192 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Linux/M.1614588577.A.A37.html
※ 编辑: ruthertw (223.137.160.192 台湾), 03/01/2021 16:54:24
1F:→ holishing: 你学弟知道怎麽查 log 吗? 知道怎麽从 03/01 17:01
2F:→ holishing: /etc/ssh/sshd_config 检查修改设定吗? 03/01 17:01
刚刚我拉出sshd_config
# $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
#ListenAddress 0.0.0.0
#ListenAddress ::
#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 prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
#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
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#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
# PermitTTY no
# ForceCommand cvs server
看起来被有心人士加了很多#
学弟说他可以用terminal连接主机.
但是他好像也不能使用sudo xxx了
※ 编辑: ruthertw (223.137.160.192 台湾), 03/01/2021 17:10:49
3F:→ holishing: 那个一堆 # 通常是系统内建给你参考的 template..... 03/01 17:12
4F:→ holishing: sudo -i 进不去 root shell? 03/01 17:13
6F:→ MOONY135: ssh -vvv username@host 可以看log 03/01 17:43
7F:→ CMJ0121: 该不会 login shell 被拔了吧? 03/01 20:08
8F:推 tomsawyer: # 是系统内建给你的设定档 预设关闭的那种 03/01 20:40
9F:→ tomsawyer: 有可能是login shell 至於sudo是sudo group被拔吧 03/01 20:40
10F:推 Hurricaneger: 把那个帐号的硬碟空间砍掉一些垃圾就可以了! 03/01 22:50
11F:推 ucrxzero: 把PermitRootLogin 开起来重新service ssh restart看看 03/04 20:01