I have a .bashrc file running on my Ubuntu server
JavaScript
x
red="[33[0;31m]"
white="[33[1;37m]"
toilet --gay -f mini " RSM PRODUCTION ";
export PS1="$white┌──[$redu$white@$redh$white]──$white[$redw$white] n└── $white"
#================================
# Alias =
#================================
alias L='ls -a -lrt'
alias l='ls -CF'
alias install='sudo apt-get install'
alias update='sudo apt-get update'
alias upgrade='sudo apt-get -u upgrade'
alias agi='sudo apt-get install'
alias agu='sudo apt-get update'
alias agg='sudo apt-get -u upgrade'
# personal aliases
alias ls='ls -hF --color' # add colors for filetype recognition
alias lx='ls -lXB' # sort by extension
alias lk='ls -lSr' # sort by size
alias la='ls -Al' # show hidden files
alias lr='ls -lR' # recursice ls
alias lt='ls -ltr' # sort by date
alias lm='ls -al |more' # pipe through 'more'
alias ll='ls -l' # long listing
alias lsize='ls --sort=size -lhr' # list by size
alias lsd='ls -l | grep "^d"' #list only directories
alias lalf='ls -alF'
alias acyl='cd ~/.icons/ACYL_Icon_Theme_0.9.3/ && bash AnyColorYouLike'
alias reboot='sudo shutdown -r now'
alias shutdown='sudo shutdown -h now'
#Command substitution
alias h='history | grep $1'
alias rm='rm -i'
alias cp='cp -v -i'
alias mv='mv -i'
alias which='type -all'
alias ..='cd ..'
#Bookmark Directory
alias dir_='cd /home/forge/rsm'
alias nginx_='cd /etc/nginx'
alias .ssh_='cd /root/.ssh'
alias ssh_='cd /etc/ssh'
alias root_='cd /root'
alias site_='cd /etc/nginx/sites-available'
alias bin_='cd /usr/local/bin'
dir_;
I can log-in to my VM perfectly fine via SSH.
I am not sure why in some SFTP client (GUI Apps) like Cyberduck
preventing me from log-in into my VM. But when remove my .bashrc or deactivating it, it works fine.
Questions
Is there a main reason behind this ?
What exactly is in my .bashrc that I shouldn’t do ?
Advertisement
Answer
Your bashrc
file probably outputs stuff to stdout, which some SFTP programs might try to interpret as SFTP commands, leading to connection or authentication failure.
You should make sure your bashrc
file only works for interactive sessions using one of those two techniques:
- Either testing the value of
PS1
(before your assignment of course) it will not be set for non-interactive sessions, or - testing if
$-
containsi
; which will only happen for interactive sessions.
So your script would look like:
JavaScript
if [[ $- == *i* ]]; then
red="[33[0;31m]"
white="[33[1;37m]"
toilet --gay -f mini " RSM PRODUCTION ";
export PS1="$white┌──[$redu$white@$redh$white]──$white[$redw$white] n└── $white"
[ ]
fi