3
1
I'd like to connect as user
to a remote host through SFTP.
Moreover, I'd like to land into a specific directory (say /home/user/dir
). I've created user with default working directory as /home/user/dir
and set a /home/user/.ssh/authorized_key
file to host my public key.
However, upon connexion using sftp -P 7000 user@host.com
and after typing user
's password, I get the following error immediatly: Connection to host.com closed by remote host. Connection closed.
Any idea about where it might come from (or how to debug that kind of issue)?
UPDATE
I was finally to connect as user
because authorized_key
didn't have the proper rights. However, I got the exact same error message while trying to land in /home/user/dir
with another user (say user2
) which was granted group access to /home/user/dir
. But as it turn out in this response, SFTP chroot jail does not allow that by design. I'll try to use symbolic links between /home/user/dir
and /home/user2/dir
to solve this issue.
1First add
-vvv
:sftp -P 7000 user@host.com -vvv
and show output – Tomasz Jakub Rup – 2018-11-09T14:24:55.637I get the exact same output :
Connection to host.com closed by remote host. Connection closed.
– Crolle – 2018-11-09T14:44:35.993Did you set /home/user/dir as your user's $HOME ? or what else did you do to "land into a specific directory" ? Did logging in work before you changed that directory? – hyph – 2018-11-09T14:52:17.357
Sorry, my fault:
sftp -P 7000 -vvv user@host.com
– Tomasz Jakub Rup – 2018-11-09T14:59:26.307@hyph I defined
– Crolle – 2018-11-09T15:42:36.483user
default directory usingusermod -m -d /home/user/dir user
@Tomasz Jakub Rup The log is quite extensive : https://pastebin.com/0dRZBPUSPlease show Your
.bashrc
file (fromhost.com
) – Tomasz Jakub Rup – 2018-11-09T19:31:04.570so then you put your dotfiles and folders in /home/user/dir not in /home/user and it should work. – hyph – 2018-11-12T17:01:14.950