Solved: TERM environment variable not set during scp.

One of the interesting issue you may face is while scp, you get an error message and the file copy is skipped.

I. Error Message

[userA@NGEL-userA saket]$ scp userA@ /tmp/
[userA@NGEL-userA saket]$ TERM environment variable not set.
[userA@NGEL-userA saket]$


II. Solution
a. Check out the term variable.

$ set | grep TERM


b. If TERM is set, it means the ssh session read out some commands in login profile file which needs a terminal.
Hence the issue here is with some echo, clear, etc commands in your .bashrc, .cshrc, or .bash_profile file.

Let me clear the text i have in my .cshrc file.

[userA@ngelinux001 ~]$ cat .cshrc
echo "Welcome $USER"

[userA@ngelinux001 ~]$ vi .cshrc
[userA@ngelinux001 ~]$

[userA@ngelinux001 ~]$ logout
Connection to closed.


III. Issue resolved: Test now

[userA@NGEL-userA saket]$ scp -P 10022 userA@ /tmp/
NGEFTP.log_ngelinux001.tar.gz                                                            100% 1002KB   1.0MB/s   00:00
[userA@NGEL-userA saket]$
3 2 votes
Article Rating
Notify of

Inline Feedbacks
View all comments