這是因為該用用戶只開通了sftp,ssh被禁了
可以通過別的主機ssh登陸這台機器
app@home:/software>ssh mysftp@192.168.0.1 Authorized only. All activity will be monitored and reported mysftp@192.168.0.1's password: This service allows sftp connections only. Connection to 192.168.0.1 closed. app@home:/software>sftp mysftp@192.168.0.1 ##成功
這是因為在server端設置的/etc/ssh/sshd_config文件中,需要設置為:
AllowTcpForwarding 應該設置為yes才可。
如果沒有設置為yes的話,用戶就只能通過sftp訪問指定目錄,而且不能進行ssh登錄.
只有把 AllowTcpForwarding no 改為 AllowTcpForwarding yes ,用戶才能通過ssh登錄然后訪問目錄。
同時ForceCommand internal-sftp也要注釋掉
#ChrootDirectory /software/sftp
#ForceCommand internal-sftp
##AllowTcpForwarding no
AllowTcpForwarding yes
然后重啟服務(roo用戶 service sshd restart),重新再試就成功了
app@home:/software>ssh mysftp@192.168.0.1 Authorized only. All activity will be monitored and reported mysftp@192.168.0.1's password: Last login: Sun Jun 2 14:22:00 2019 from 192.168.102.82 mysftp@remoteServer:/home/ap/mysftp>ll