If you are getting this error it's probably because you have one or more echo statments on your .bashrc or .bash_profile files (like we did here - customizing your bash shell with a welcome message or your nic's ips).

Well, i found this script (here), and it allows to verify if a shell is a login shell or not and if it is (i.e. vsftp) all we need to do is not to echo anything. It's not perfect but it's the better solution I could find (let me know if you have a better one).

function is_ssh() {
  p=${1:-$PPID}
  read pid name x ppid y < <( cat /proc/$p/stat )
  # or: read pid name ppid < <(ps -o pid= -o comm= -o ppid= -p $p) 
  [[ "$name" =~ sshd ]] && { echo "Is SSH : $pid $name"; return 0; }
  [ "$ppid" -le 1 ]     && { echo "Adam is $pid $name";  return 1; }
  is_ssh $ppid
}

is_ssh $PPID
exit $?

Here's the end result:

 

If you want you can print a welcome message that will show every time you login or launch a new terminal.

To do that you just have to edit your .bashrc file or your .bash_profile if you just want to display the message in login shells (and not in no-login shells) and add the line :

echo " ********* Welcome $USER ********** "

like you see here:

Subscreva a Newsletter

maker.akanerd.com

    • Neste site, procura-se documentar alguns projectos do seu mentor, projectos esses, relacionados com áreas como a electrónica, a automação industrial, a informática, desenvolvimento web, sistemas operativos e redes de computadores, entre outros. Conta também com uma área educacional (akanerdemy), onde se apresentam video tutorias nas referidas áreas.