Problem with scp (ssh) on adding /usr/bin/fortune to /etc/profile & .bashrc (Fedora)
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Problem with scp (ssh) on adding /usr/bin/fortune to /etc/profile & .bashrc (Fedora)
Hi everyone,
I kinda like the fortune messages, so I added /usr/bin/fortune to both my ~/.bashrc and /etc/profile (the latter because i wanted this to be system wide, so was looking for alternative to adding this line to the bashrc of every user..not sure if this is the correct way).
Anyway, now I'm unable to scp (ssh-copy) a file from this machine, by logging in from another machine. When I try this from machine B:
B~>scp A:<file> ./
password:
When I enter the password, I get the /usr/bin/fortune message, instead of the file transfer starting
What am I doing wrong?
[root@localhost ~]# scp mkaushik@blah:~/work/bugs/xyz .
mkaushik@blah's password:
I could dance with you till the cows come home. On second thought, I'd rather
tail ~/.bashrc:
Code:
if [ ! -z "PS1" ]; then
/usr/bin/fortune
echo -e "\n"
fi
Any output coming from a command in .bashrc can trigger the scp errors. Moreover if you execute remote commands using ssh, the output will come out together with the requested one. For example when you do something like
Code:
ssh user@host ls
the fortune message will be "listed" together with the list of files. To prevent this behaviour, put the fortune command in .bash_profile. You will get the output when you login through ssh, but not when using scp or when issuing remote commands.
Why does my .bash_profile not get executed when i login?
Code:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
echo -e "Test\n"
PATH=$PATH:$HOME/bin
export PATH
/usr/bin/fortune
echo -e "\n"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.