Loging with SSH with a different user, shows no current path [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am trying to get a server up and running, there is no problem when I am using my root user, however when I created a new user and I log in with him instead of getting
user#internet:/$
I am only geting $ and I can't see the folder in which I am.
The server is running ubuntu if that helps.

Your new user is probably using a different shell. You can check by typing $0 at the prompt in each.
It sounds like root is using bash and your new user is using sh, but do the above to check.
If you want to modify the login shell for your new user, use usermod with the -s flag:
usermod user -s /bin/bash
The above would set the default shell to bash.

It's because your user runs sh as default shell.
Run as root:
chsh -s /bin/bash your_user
And login again.

Related

su - username command doesn't act as expected [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 months ago.
Improve this question
I am trying to switch to another user using su command, but it doesn't work as expected.
What I am expecting:
[root#ubuntu ~]# su testuser
[testuser#ubuntu root]#
What actually happens:
[root#ubuntu ~]# su testuser
bash-4.2$
whoami command:
bash-4.2$ whoami
testuser
The testuser might not have the same bash configuration. So the prompt might look different. Check the current user with whoami after you switched the user.

Bash script check permissions to run command on remote [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have a local development machine and from my bash script am sending commands to the remote server.
How can I write bash code to check if I am allowed to run the remote command so that I can handle the success/failure response from my script?
Alternatively, how can I capture the output so that I can parse it and detect if it succeeded. The difficulty with parsing is that the ssh command might trigger a password prompt so I can't interfere with that.
That bash script uses ssh -qt to send the remote commands
Command
ssh user#host -qt "sudo -u www /usr/local/bin/php /mnt/data/script.php"
Output:
[sudo] password for xxx:
Sorry, user xxx is not allowed to execute '/usr/local/bin/php /mnt/data/script.php' as www on host.domain.com
Assuming that user != root above: you can't - there's no way to read /etc/sudoers or /etc/sudoers.d/* in a normally set-up Linux box if you're not root, so apart from trial & error there's nothing to be done.
As for capturing the result - that's fairly simple (parsing it, of course, is a different story, depending on what you're doing over there).
output=$( ssh user#host -qt "sudo -u www /usr/local/bin/php /mnt/data/script.php" 2>&1 )
After the execution (and you typing the password for sudo)
echo $? # gives you the return-code of what happened on the far end, if it's a success that should be 0
echo $output # gives you the strings to parse

How do I run `forever` from Crontab? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I am trying to schedule node server restart on OS reboot (Ubuntu 16.04 LTS). I wrote:
crontab -u username -e
then I added following line:
#reboot /usr/local/bin/forever start -c /usr/bin/node /home/username/node/bin/www
I get the success message after saving or updating this file. There seems to be no effect on server reboot.
I'd wrap that into a bash script in the user's home directory's bin.
/home/username/bin/start_my_node_app.sh
Then in your crontab...
#reboot /home/username/bin/start_my_node_app.sh >/dev/null 2>&1
Though according to this article, #reboot may not work for non-root users.
https://unix.stackexchange.com/questions/109804/crontabs-reboot-only-works-for-root

Issue with changing login shell [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I want to change the default login shell on my Ubuntu.
To change the shell I ran the following:
$ chsh -s /usr/bin/zsh
After that I restart my terminal but my default shell is still bash.
$ echo $SHELL
/bin/bash
These are shells installed on my machine:
$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/bin/zsh
/usr/bin/zsh
Record for my user in /etc/passwd is also changed like expected:
$ cat /etc/passwd|grep myuser
myuser:x:1000:1000:myuser,,,:/home/myuser:/usr/bin/zsh
I successfully changed my login shell the same way on my mac but I seem to be having some issue on Ubuntu. Am I missing something here?
You need to logout and log back into Ubuntu so that your GUI based X terminal shells pick up the new shell value.
Note: Ctrl+Alt+F[1-6] represent 6 virtual shells while GUI login is on Ctrl+Alt+F7

How to set up an SSH Server on OS X [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm planning on making a Bash script that sets up an SSH server. The script is only meant to work on a computer running OS X. With the research I have conducted it seems like you have to use the GUI to enable SSH. Is their a way to enable SSH through Terminal and then create a script that does so?
You can enable it from the command line (or a shell script) with:
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
You might also want to regulate access to the ssh service with the com.apple.access_ssh group:
sudo dseditgroup -o edit -a usernametoallow -t user com.apple.access_ssh
sudo dseditgroup -o edit -a otherusernametoallow -t user com.apple.access_ssh
sudo dseditgroup -o edit -a groupnametoallow -t group com.apple.access_ssh
...after which only usernametoallow, otherusernametoallow, and members of groupnametoallow will be able to ssh into the Mac.

Resources