[問題] Ubuntu突然scp可以登入但ssh不能登入

看板Linux作者 (督人無數就是我)時間3年前 (2021/03/01 16:49), 3年前編輯推噓3(308)
留言11則, 6人參與, 3年前最新討論串1/1
有一陣子沒有登入實驗室主機(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://www.ptt.cc/bbs/Linux/M.1614588577.A.A37.html ※ 編輯: ruthertw (223.137.160.192 臺灣), 03/01/2021 16:54:24

03/01 17:01, 3年前 , 1F
你學弟知道怎麼查 log 嗎? 知道怎麼從
03/01 17:01, 1F

03/01 17:01, 3年前 , 2F
/etc/ssh/sshd_config 檢查修改設定嗎?
03/01 17:01, 2F
剛剛我拉出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

03/01 17:12, 3年前 , 3F
那個一堆 # 通常是系統內建給你參考的 template.....
03/01 17:12, 3F

03/01 17:13, 3年前 , 4F
sudo -i 進不去 root shell?
03/01 17:13, 4F

03/01 17:41, 3年前 , 5F
https://reurl.cc/4yjVp3 感覺是這篇的反過來
03/01 17:41, 5F

03/01 17:43, 3年前 , 6F
ssh -vvv username@host 可以看log
03/01 17:43, 6F

03/01 20:08, 3年前 , 7F
該不會 login shell 被拔了吧?
03/01 20:08, 7F

03/01 20:40, 3年前 , 8F
# 是系統內建給你的設定檔 預設關閉的那種
03/01 20:40, 8F

03/01 20:40, 3年前 , 9F
有可能是login shell 至於sudo是sudo group被拔吧
03/01 20:40, 9F

03/01 22:50, 3年前 , 10F
把那個帳號的硬碟空間砍掉一些垃圾就可以了!
03/01 22:50, 10F

03/04 20:01, 3年前 , 11F
把PermitRootLogin 開起來重新service ssh restart看看
03/04 20:01, 11F
文章代碼(AID): #1WFAgXet (Linux)
文章代碼(AID): #1WFAgXet (Linux)