我试图限制一个新添加的用户到他的homedir / home /用户名。 不要让他能够从中解脱出来。
我有这个我的sshd_config:
Match User username ChrootDirectory %h X11Forwarding no AllowTcpForwarding no ForceCommand internal-sftp
我使用chown将/ home / username目录的所有者设置为root,并将权限设置为755。
还将用户添加到chroot.conf。
重新启动sshd。 但是当我尝试与用户login时,我得到一个由远程服务器closures的连接。
更新:
SSH输出(从IP地址和RSA密钥中编辑出一些信息):
OpenSSH_5.9p1, OpenSSL 0.9.8x 10 May 2012 debug1: Reading configuration data /Users/Mate/.ssh/config debug1: Reading configuration data /etc/ssh_config debug1: /etc/ssh_config line 20: Applying options for * debug1: /etc/ssh_config line 53: Applying options for * debug1: Connecting to (IP address) [IP address] port 22. debug1: Connection established. debug1: identity file /Users/Mate/.ssh/id_rsa type 1 debug1: identity file /Users/Mate/.ssh/id_rsa-cert type -1 debug1: identity file /Users/Mate/.ssh/id_dsa type -1 debug1: identity file /Users/Mate/.ssh/id_dsa-cert type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: match: OpenSSH_5.3 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.9 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-md5 none debug1: kex: client->server aes128-ctr hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Server host key: Some key debug1: Host 'IP address' is known and matches the RSA host key. debug1: Found key in /Users/Mate/.ssh/known_hosts:13 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/Mate/.ssh/id_rsa debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive debug1: Trying private key: /Users/Mate/.ssh/id_dsa debug1: Next authentication method: keyboard-interactive Password: debug1: Authentication succeeded (keyboard-interactive). Authenticated to IP address ([IP address]:22). debug1: channel 0: new [client-session] debug1: Requesting [email protected] debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LC_CTYPE = UTF-8 debug1: channel 0: free: client-session, nchannels 1 Connection to IP address closed by remote host. Connection to IP address closed. Transferred: sent 2400, received 2008 bytes, in 0.2 seconds Bytes per second: sent 10399.6, received 8701.0 debug1: Exit status -1
任何想法为什么发生这种情况
是。 你强迫他只用sftp协议连接,使用ForceCommand internal-sftp 。 毫不奇怪,这意味着他不能ssh进入。