Screen "Must be connected to a Terminal." - ssh

I'm on a Debian OS.
I'm trying to use screen under a SSH session. But when I'm trying to run the command
screen
the shell answer me :
Must be connected to a Terminal.
If I enter
tty
it answer me :
Not a tty
I don't know why and I try
ssh -t login#server
it doesn't work..
Please help me I really need this !
Thanks
EDIT :
I read this topic but it still doesn't work

I had the same problem. If you get this error while in a chroot, here is what helped me:
(run these commands from outside the chroot)
$ sudo mount -o bind /dev /home/chroot/dev
$ sudo mount -t proc proc /home/chroot/proc
$ sudo mount -t devpts devpts /home/chroot/dev/pts
/home/chroot being the path to your chroot, obviously. Update above commands accordingly.
source: http://www.howtoforge.com/forums/showthread.php?t=23583#post128768
(see also http://forums.gentoo.org/viewtopic-t-433006-start-0.html)

Try the following:
getty tty
...and then relaunch:
screen
If you don't have getty, you could try installing it:
apt-get install getty

Related

The web server not permitted for chmod under WSL Ubuntu

I use Ubuntu 18 as WSL and everything was running well. Today I run the apache and started the application. When the app tried to perform chmod() on a file which was submited through form inside the folder project (I use Laravel), I received the following error:
chmod(): Operation not permitted
I have notice that this error happen when I try running chmod() from web server (www-data user). In the cli I dont have problems.
From other posts over the net, I understand that Windows has some changes regarding WSL permissions and drive mounts. But I didnt get answer or didnt succeed to resolve that issue.
sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata
Reference: https://github.com/Microsoft/WSL/issues/3172#issuecomment-389157376
sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata,uid=1000,gid=1000,umask=22,fmask=111
did the trick for me.
Ref: https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/

how does fabric execute commands?

i am wondering how does fabric execute commands.
Let's say I give him env.user=User, env.host=HOST. Then i ask him to sudo('ls')
Is that equivalent to me typing in a shell : ssh User#host 'sudo(/bin/ls)'
or it's more : ssh User#host in a first time, then sudo ls commande in a seconde time ?
I'm asking that because sometimes using a shell, if the TTY has a bad configuration (I am a bit blurry on this), ssh User#Host 'sudo /bin/ls'
return : sudo: no tty present and no askpass program specified
but you can first log in with ssh User#Host then sudo ls and it works.
I don't know how to replicate the no tty error, but I know it can occurs. Would this block the sudo commande from Fabric?
Basically how it works is:
First a connection is established (equivalent as doing ssh User#host)
Over this connection a command is executed as follows:
sudo -S -p 'sudo password:' /bin/bash -l -c "your_command"
You can also allow Fabric not to request a pty with either pty=False argument, env.always_use_pty=False or --no-pty commandline option.

Synaptics Touch Pad disables after login

I'm on KDE using plasma5 on NixOS, and for some reason my touch pad is disabling after logging in with KDM. Here is the output of synclient -l right after booting. What would cause this issue? Any guidance would be very much appreciated.
Having the same problem with KDE on debian with my t440p and opened an issue for the synaptics package. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770923
But I found a workaround in the ubuntu forum to use "imps". It has the disadvantage that you can't disable the touchpad an the virtual buttons separately. Better than nothing. Maybe it might help you too.
https://askubuntu.com/questions/262287/synaptic-touchpad-on-laptop-not-working/262364#262364?newreg=acf9a725adb249169b5dad26ac731c17
Try:
sudo modprobe -r psmouse
sudo modprobe psmouse proto=imps
make some changes in your grub file:
1.sudo nano /etc/default/grub
2.Add “i8042.notimeout i8042.nomux” to the line which says 3.GRUB_CMDLINE_LINUX=”…”.
4.sudo update-grub
5.sudo apt-get install kde-config-touchpad && synaptiks
edit touchpad file:
6.sudo nano /etc/pm/sleep.d/restart_touchpad.sh
7. Enter the following code:
#!/bin/sh
case “$1” in
resume)
modprobe -r psmouse
modprobe psmouse
esac
exit 0
7.sudo chmod +x /etc/pm/sleep.d/restart_touchpad.sh
8.sudo reboot.
follow all step correctly.

autossh not working and run without any error message

I have no problem when running this command on ssh , but in autossh its not working.
the list of command i have done till now :
1- ssh-keygen -t rsa
2- cp id_rsa.pub /home/sshUser/.ssh/authorized_keys2/
3- cp id_rsa /home/sshUser/.ssh/authorized_keys2/
4- autossh -fNg -L 3307:127.0.0.1:3306 sshUser#10.100.20.25
and after the last line nothing happen.
ssh still done and ive check it with : "sudo lsof -i -n | egrep '\'"
but if i use ssh instead of autossh it works.
I ran into a very similar problem: autossh would not react, but show the help text.
The solution is to add the monitoring port, i.e. the -M <port> parameter. If you set -M 0 monitoring will be disabled.
Unfortunately until the current Version 1.40, the help shows the -M parameter as optional. This is an known problem.
On Linux Mint 17 (~Ubuntu 14.04), I need to run autossh as sudo in order to have it to work.

set environment variable SSH_ASKPASS or askpass in sudoers, resp

I'm trying to login to a ssh server and to execute something like:
ssh user#domain.com 'sudo echo "foobar"'
Unfortunately I'm getting an error:
sudo: no tty present and no askpass program specified
Google told me to either set the environment variable SSH_ASKPASS or to set askpass in the sudoers file. My remote machine is running on Debian 6 and I've installed the packages ssh-askpass and ssh-askpass-gnome and my sudoers file looks like this:
Defaults env_reset
Defaults askpass=/usr/bin/ssh-askpass
# User privilege specification
root ALL=(ALL) ALL
user ALL=(ALL) ALL
Can someone tell what I'm doing wrong and how to do it better.
There are two ways to get rid of this error message. The easy way is to provide a pseudo terminal for the remote sudo process. You can do this with the option -t:
ssh -t user#domain.com 'sudo echo "foobar"'
Rather than allocating a TTY, or setting a password that can be seen in the command line, do something like this.
Create a shell file that echo's out your password like:
#!/bin/bash
echo "mypassword"
then copy that to the node you want using scp like this:
scp SudoPass.sh somesystem:~/bin
Then when you ssh do the following:
ssh somesystem "export SUDO_ASKPASS=~/bin/SudoPass.sh;sudo -A command -parameter"
Another way is to run sudo -S in order to "Write the prompt to the standard error and read the password from the standard input instead of using the terminal device" (according to man) together with cat:
cat | ssh user#domain.com 'sudo -S echo "foobar"'
Just input the password when being prompted to.
One advantage is that you can redirect the output of the remote command to a file without "[sudo] password for …" in it:
cat | ssh user#domain.com 'sudo -S tar c --one-file-system /' > backup.tar
Defaults askpass=/usr/bin/ssh-askpass
ssh-askpass requires X server, so instead of providing a terminal (via -t, as suggested by nosid), you may forward X connection via -X:
ssh -X user#domain.com 'sudo echo "foobar"'
However, according to current documentation, askpass is set in sudo.conf as Path, not in sudoers.
How about adding this in the sudoers file:
user ALL=(ALL) NOPASSWD: ALL