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?

womble
  • 96,255
  • 29
  • 175
  • 230
user485485
  • 11
  • 1

2 Answers2

3

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

HBruijn
  • 77,029
  • 24
  • 135
  • 201
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 ?

John Doe
  • 495
  • 1
  • 6
  • 12