1. 程式人生 > >關於linux上面ssh和sftp到某臺伺服器出現Permission denied, please try again.

關於linux上面ssh和sftp到某臺伺服器出現Permission denied, please try again.

最近在阿里雲上面部署了兩臺伺服器。伺服器a(圖片伺服器)和伺服器b(主程式),b是通過java的jsch這個框架來往a傳送圖片的,但是最近傳送在b上面操作sftp的時候一直在報

[[email protected] ~]# sftp [email protected]
Connecting to 192.168.1.11...
[email protected]'s password: 
Permission denied, please try again.
一直報以上的錯誤,通過各種配置都不行,最後調通了b到a無密碼登入的,但是通過程式java的jsch去連的時候會報
Apr 20 10:55:35 iZ2380a1u1tZ sshd[27326]: Failed password for ftp_1 from *.*.*.* port 33118 ssh2
Apr 20 10:55:35 iZ2380a1u1tZ sshd[27327]: Received disconnect from *.*.*.*: 3: com.jcraft.jsch.JSchException: Auth fail
以下是sshd的debug日誌
 : Apr 20 10:55:33 iZ2380a1u1tZ sshd[25188]: debug1: Forked child 27326.
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: Set /proc/self/oom_score_adj to 0
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: rexec start in 4 out 4 newsock 4 pipe 6 sock 7
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: inetd sockets after dupping: 3, 3
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: Connection from 192.168.1.11 port 33118
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: Client protocol version 2.0; client software version JSCH-0.1.51
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: no match: JSCH-0.1.51
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: Enabling compatibility mode for protocol 2.0
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: Local version string SSH-2.0-OpenSSH_5.3
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: permanently_set_uid: 74/74
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: list_hostkey_types: ssh-rsa,ssh-dss
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: SSH2_MSG_KEXINIT sent
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: SSH2_MSG_KEXINIT received
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: kex: client->server aes128-ctr hmac-md5 none
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: kex: server->client aes128-ctr hmac-md5 none
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: expecting SSH2_MSG_KEXDH_INIT
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: SSH2_MSG_NEWKEYS sent
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: expecting SSH2_MSG_NEWKEYS
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: SSH2_MSG_NEWKEYS received
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: KEX done
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: userauth-request for user test_1 service ssh-connection method none
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: attempt 0 failures 0
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: PAM: initializing for "test_1"
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: userauth-request for user test_1 service ssh-connection method gssapi-with-mic
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: attempt 1 failures 0
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: PAM: setting PAM_RHOST to "192.168.1.11"
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: PAM: setting PAM_TTY to "ssh"
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: Unspecified GSS failure.  Minor code may provide more information\nKey table file '/etc/krb5.keytab' not found\n
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: userauth-request for user test_1 service ssh-connection method password
Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: attempt 2 failures 0
Apr 20 10:55:35 iZ2380a1u1tZ sshd[27326]: debug1: PAM: password authentication failed for test_1: Authentication failure
Apr 20 10:55:35 iZ2380a1u1tZ sshd[27326]: Failed password for test_1 from 192.168.1.11 port 33118 ssh2
Apr 20 10:55:35 iZ2380a1u1tZ sshd[27327]: Received disconnect from 192.168.1.11: 3: com.jcraft.jsch.JSchException: Auth fail
Apr 20 10:55:35 iZ2380a1u1tZ sshd[27327]: debug1: do_cleanup
Apr 20 10:55:35 iZ2380a1u1tZ sshd[27326]: debug1: do_cleanup
Apr 20 10:55:35 iZ2380a1u1tZ sshd[27326]: debug1: PAM: cleanup

以下是/etc/sshd/sshd_config的配置


#       $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 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/local/bin:/bin:/usr/bin

# 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 change a
# default value.

#Port 22
#ListenAddress 0.0.0.0
#ListenAddress ::

# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Logging
# obsoletes QuietMode and FascistLogging
LogLevel debug

# Authentication:

#LoginGraceTime 2m
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys
#AuthorizedKeysCommand none
#AuthorizedKeysCommandRunAs nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and 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!
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes

# GSSAPI options
GSSAPIAuthentication no
#GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
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
# PAM authentication via ChallengeResponseAuthentication may bypass
# If you just want the PAM account and session checks to run without
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no
UsePAM yes

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
UseLogin yes
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem       sftp    /usr/libexec/openssh/sftp-server
#Subsystem sftp internal-sftp

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       ForceCommand cvs server
#UseDNS yes
UseDns no
AddressFamily inet
PermitRootLogin yes
SyslogFacility AUTHPRIV
PasswordAuthentication yes

最後是把use PAM設定成為no才能正常的sftp和ssh到a伺服器,真是太辛苦了,整整搞了一天


相關推薦

關於linux上面sshsftp伺服器出現Permission denied, please try again.

最近在阿里雲上面部署了兩臺伺服器。伺服器a(圖片伺服器)和伺服器b(主程式),b是通過java的jsch這個框架來往a傳送圖片的,但是最近傳送在b上面操作sftp的時候一直在報 [[email protected] ~]# sftp [email pro

debian ssh設置root權限登陸 Permission denied, please try again

play then ren del sftp ports seda ces ecif 1.安裝ssh服務 root@debian:/# apt-get install ssh 2.進入/etc/ssh/修改sshd_config配置文件,讓其可以root權限登陸該服務

樹莓派普通使用者ssh出現Permission denied, please try again的解決方法

拿到了樹莓派板子就想用遠端SSH的功能,網上看到了一些教程都是用預設使用者pi做SSH,我自己建立的使用者每次都是Permission denied, please try again. 後來找到了問題的答案,輸入: [email protecte

ECS伺服器ssh登入提示“Permission denied, please try again

原文地址:http://www.aiuxian.com/article/p-3184397.html 原因:                不用懷疑,一般情況下,就是你密碼輸入錯誤了。 解決:                找到正確的密碼輸入。 當然,也有可能是下面

遠端登入阿里雲伺服器時,提示Permission denied, please try again.

在使用ssh命令,遠端登入阿里雲伺服器時,提示Permission denied, please try again. 百分之九十的可能:你的密碼錯了! 你需要注意的是,我們的例項有兩個密碼 暫且稱呼它們為複雜密碼和簡單密碼,看一下兩個密碼的設定格式: 複雜密碼:

密碼正確,SSH無法登陸Received disconnect from ***: Too many /Permission denied, please try again.

下午嘗試**把本地windows系統檔案上傳到多個linux伺服器**, 因為windows系統本身不支援ssh協議,所以,要想上面的命令成功執行,必須在windows客戶端安裝ssh for windows的客戶端軟體, 於是在本地win10上安裝ssh客

解決Ubuntu的root賬號無法登入SSH問題-Permission denied, please try again.

有時,我們登入SSH的時候,會出現如下問題: 此時,是因為系統預設禁止root使用者登入ssh,此時我們可以這樣解決: 首先,Ctrl+C退出密碼輸入介面: 然後輸入:su - tips:一定是su -,不是su 然後出現如下介面: 然後,我們編輯

在Mac上面用終端登陸阿里雲伺服器permission denied

在使用Mac終端登陸到阿里雲伺服器時,出現如下提示: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 解決方案: 1、連線到阿里雲伺服器,可以用控制檯的命令直譯器,也可以用xshell

Git使用SSH提交代碼到server出現 permission denied (publickey).

space lin none ssh-key denied .net 過程 geo rep 在GitBush中向已經存在的Repository提交README.md改動。命令例如以下: touch README.md git init git add README

Mac終端連線阿里雲伺服器出現Permission denied (publickey)

阿里雲伺服器版本:Ubuntu 16.04 64位 用Mac終端連線伺服器時出現錯誤:Permission denied (publickey) 用阿里雲Web終端(就是那個網頁終端)或者X

Linux SSHSFTP服務分離

HA title clas linux log logs .com class ID Linux SSH和SFTP服務分離 學習了:https://www.cnblogs.com/zihanxing/articles/5665383.html 都是監聽22端口; Li

Linux部署WEB專案,一伺服器部署兩個Tomcat兩個專案

      首先安裝JDK+Tomcat和配置好環境變數,部署第一個專案是比較簡單,本文主要是針對部署第二個專案的時候出現的一些問題和解決辦法進行敘述。可能解決辦法有很多種,目的都是為了解決遇到的問題。我們公司一直以來採用的是Nginx+Tomcat進行專案部署。  第一個專

使用 SSH SFTP 協議

通過 SSH 和 SFTP 協議,我們能夠訪問其他裝置,有效而且安全的傳輸檔案等等。 幾年前,我決定配置另外一臺電腦,以便我能在工作時訪問它來傳輸我所需要的檔案。要做到這一點,最基本的一步是要求你的網路提供商(ISP)提供一個固定的地址。 有一個不必要但很重要的步驟,就是保證你的這個可以訪問的系統是安全的

windows伺服器區域網內與伺服器時間同步

時間同步有兩個端,如下: ntp server(被同步的伺服器) ntp client (要同步的伺服器) 一、被用來做同步的,參照伺服器配置   首先在被用來做同步的,參照伺服器上,開啟ntp server相應服務,方法如下: 1、啟

Linux上面安裝配置mysql服務

安裝mysql 檢查是否安裝mysql: rpm -qa |grep mysql 刪除已經安裝的mysql: rpm -e mysql-libs-5.1.71-1.el6.x86_64 報錯:因為mysql有相關依賴,並不能直接刪除 rpm -e --nodeps mysql-libs

hdfs伺服器datanode服務佔用cpu過高

1、問題描述 檢視一下6834的程序是hadoop的datanode服務,可以看到cpu負載過高。 2、解決方法 (1) 關閉大頁記憶體:echo never > /sys/kernel/mm/redhat_transparent_hug

SSHSFTP簡介

傳統FTP在傳輸機制和實現原理上是沒有考慮安全機制的,因為它們在網路上用明文傳送資料、使用者帳號和使用者口令,別有用心的人非常容易地就可以截獲這些資料、使用者帳號和使用者口令。而且,這些網路服務程式容易受到“中間人”(man-in-the-middle)這種攻擊方式的攻擊。所

linux下rsync+inotify實現兩伺服器檔案實時同步

假設兩個伺服器: 192.168.0.1 源伺服器  有目錄 /opt/test/ 192.168.0.2 目標伺服器  有目錄 /opt/bak/test/ 實現的目的就是保持這兩個伺服器某個檔案目錄保持實時同步 實現方式: 通過rsync+inotify-too

CentOS 7部署chroot sshsftp監牢

看過很多文章,講如何部署ssh/sftp監牢,但全部都是ssh遠端登入後,進入監牢,卻無法使用外部命令,即只有pwd、echo、h

Paramiko的SSHSFTP使用

目錄 1. 概述 2. Paramiko的基本使用 2.1 SSHClient關鍵引數介紹 2.2 SSHClient常用示例 2.2.1 通過使用者名稱和密碼方式登陸: 2.