no tty

after gaining a shell, a tty might not always be available

there’ll be problems using any application that requires a password (ssh, mysql, passwd, sudo, su, …)

here are some of the workarounds i’ve had to use so far

# use python to get a tty
python -c “import pty; pty.spawn(‘/bin/bash’)”

# use expect to get a tty
expect -c “spawn bash; interact”

# change a password (not all passwd variants support –stdin)
echo -n password | passwd –stdin root

# change a password (must be root or able to sudo -S or with no NOPASSWD)
echo ‘root:foobar123’ | chpasswd

# sudo requiring password (not all variants support -S)
echo password | sudo -S ./foo.sh

# mysql commands without terminal
mysql -u root –password=”” -e “SELECT host, user, password FROM mysql.user;”

# if stderr isn’t being received, find out what happened
./whatever.sh 2>&1

Leave a Reply

Your email address will not be published. Required fields are marked *