1

I'm trying to use a specific bash script as a user shell. So that if the user logs in, the script will be executed.

I've created the script and placed it into the home directory for the specific user. I modified /etc/passwd to use the script as a shell for this user.

This works great if I'm login locally. But if I try to login over SSH, I get the following error:

/home/user/custom-shell: No such file or directory Connection to xyz closed. 

The path to this script is correct since I'm able to login locally and can see that the script will be executed.

I also tried to change the permission using chmod 777 custom-shell, but that didn't help either.

Do you have an idea what's the problem?

1
  • Does the script begin with #!/bin/bash as first line? Commented Aug 30, 2018 at 9:51

2 Answers 2

3

Add the script/program you wish to use for a shell to /etc/shells

1
  • I use scripts as login shell for some users, and the work with SSH without being in /etc/shells. Commented Aug 30, 2018 at 15:51
0

can I see the line you entered to /etc/passwd as well as the script and it's permissions ? I've tested it locally and it works well:

[root@ops-tricks ~]# grep jdoe /etc/passwd jdoe:x:1010:1010::/home/jdoe:/home/jdoe/custom-shell [root@ops-tricks ~]# cat /home/jdoe/custom-shell #!/bin/bash echo "Custom Shell" [root@ops-tricks ~]# su - jdoe Custom Shell [root@ops-tricks ~]# ssh jdoe@localhost jdoe@localhost's password: Last login: Mon Sep 3 23:32:25 2018 Custom Shell Connection to localhost closed. [root@ops-tricks ~]# ls -l /home/jdoe/custom-shell -rwxr-xr-x. 1 root root 33 Sep 3 23:28 /home/jdoe/custom-shell 

Also , what distribution and version are you running ?

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.