这是因为该用用户只开通了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

 

posted on 2019-06-02 14:41  pu20065226  阅读(9721)  评论(0编辑  收藏  举报