scp: copy a file from local machine to remote machine
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
scp: copy a file from local machine to remote machine
Hi,
This is Seran. I tried to copy a file from my local machine to a remote machine using the scp (Secure Copy) linux command. This is what I gave:
$ scp <filename> seran@<ip address of remote>:<target dir>
It asked my password and after entering it, I got the following error message.
TERM environment variable not set
In my machine the value of the TERM environment variable is 'linux'.
Using ftp I was able to copy. Why scp is giving problem.
Can any one explain me how to trace the problem.
If he is asked for his password, I suspect ssh is running on the destination host. If not, it's a trick I would love to learn
First of all, whenever I run into weird stuff with ssh or scp, I use the -v (verbose) option. It often enables you to see where something goes wrong and where you might find the solution. It also provides people that could help you with useful information.
Also, try to log on to the server with ssh and type
Code:
# echo ${TERM}
I'm just taking a poke here, but perhaps the term variable of your login is not set on the destination server. If it is not, you could edit the .profile file in your homedir yourself and add it.
It's a year later, so guess this isn't a directly useful answer, but I just encountered a similar problem and, since this is one of the very few places online to mention the scp / TERM variable problem, I thought I'd post the solution I found.
My problem was that in my .bashrc file I had used the "clear" shell builtin command to refresh the terminal, but the "dumb" terminal type used by scp doesn't support that operation, hence the (rather misleading) error. The answer was to only execute the "clear" if the terminal is not "dumb":
Code:
## in .bashrc
test "dumb" != $TERM && clear
## as opposed to just calling "clear" without thinking about terminal support
I initially tried to solve this by only calling clear from within an "if [ $PS1 ]; then ..." block (to detect an interactive shell) but that didn't work on all machines... some systems still set the PS1 variable even if it isn't an interactive shell.
You may also need to do a similar protection on the "trap" command, if you use that to clear the terminal on logout from a remote machine.
I just wanted to share my solution which I found. In my remote machine's /etc/bashrc file the following three lines were present at the end.
.....
clear
/usr/games/fortune
echo
I know the root passwd of the remote machine, so I commented first, "clear" and then tried to scp from my machine. I didnt get the "TERM environment variable not set" error, but I got the fortune message on my screen and file was also not copied. Then I commented "/usr/games/fortune"(now both clear and fortune lines are commented) and tried, no error message was displayed and file was not copied.
At last I commented all the last three lines "clear", "fortune", and "echo". Now I was able to do scp.
Thanks for taking interest and giving some suggestions.
For what it is worth, nearly three years on from the original thread. Bash has a variable that indicates whether the shell is interactive or not. Have a look at http://www.gnu.org/software/bash/man...ref.html#SEC75. I used the following example to detect if my shell was interactive or not:
Code:
case "$-" in
*i*) echo This shell is interactive ;;
*) echo This shell is not interactive ;;
esac
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.