# scp acting like ssh

## pintnight

When I try to copy a file from or to my server with scp, scp is acting like I'm using ssh.  Why is it trying to login as a terminal instead of copying the file?

Here is the output.

```

username@servername.com's password:

TERM environment variable not set.

I value kindness to human beings first of all, and kindness to animals.  I
```

----------

## red_over_blue

Can you ssh into the same machine?

----------

## pintnight

 *red_over_blue wrote:*   

> Can you ssh into the same machine?

 

Yes, I can ssh just fine into the machine.  Just scp is wanting to be like ssh instead of copying the file.

----------

## red_over_blue

Can you post the full command you are using for scp?

----------

## shadow255

Can you post some output from scp -v, and possibly the sshd_config file from the server?  It might also be helpful to show us the command you're issuing in its entirety.  You might be able to spot the source of the problem yourself looking over some debugging output, but no one can help you with your issues without seeing it as well.

----------

## pintnight

 *red_over_blue wrote:*   

> Can you post the full command you are using for scp?

 

```
scp username@servername.com:tmp/a.txt .
```

----------

## shadow255

 *pintnight wrote:*   

>  *red_over_blue wrote:*   Can you post the full command you are using for scp? 
> 
> ```
> scp username@servername.com:tmp/a.txt .
> ```
> ...

 

I'd suggest instead:

```
scp username@servername.com:tmp/a.txt ./
```

If you still have trouble, give us some debug output, e.g. the results from:

```
scp -v username@servername.com:tmp/a.txt ./
```

----------

## pintnight

 *shadow255 wrote:*   

> Can you post some output from scp -v, and possibly the sshd_config file from the server?  It might also be helpful to show us the command you're issuing in its entirety.  You might be able to spot the source of the problem yourself looking over some debugging output, but no one can help you with your issues without seeing it as well.

 

scp with the -v option

```

username@taos tmp $ scp -v username@servername.com:/home/username/tmp/a.txt .

Executing: program /usr/bin/ssh host servername.com, user username, command scp -v -f /home/username/tmp/a.txt

OpenSSH_3.6.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090609f

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: Rhosts Authentication disabled, originating port will not be trusted.

debug1: Connecting to servername.com [216.234.228.107] port 22.

debug1: Connection established.

debug1: identity file /home/username/.ssh/identity type -1

debug1: identity file /home/username/.ssh/id_rsa type -1

debug1: identity file /home/username/.ssh/id_dsa type -1

debug1: Remote protocol version 2.0, remote software version OpenSSH_3.6.1p2

debug1: match: OpenSSH_3.6.1p2 pat OpenSSH*

debug1: Enabling compatibility mode for protocol 2.0

debug1: Local version string SSH-2.0-OpenSSH_3.6.1p2

debug1: SSH2_MSG_KEXINIT sent

debug1: SSH2_MSG_KEXINIT received

debug1: kex: server->client aes128-cbc hmac-md5 none

debug1: kex: client->server aes128-cbc hmac-md5 none

debug1: SSH2_MSG_KEX_DH_GEX_REQUEST sent

debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP

debug1: SSH2_MSG_KEX_DH_GEX_INIT sent

debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY

debug1: Host 'servername.com' is known and matches the RSA host key.

debug1: Found key in /home/username/.ssh/known_hosts:1

debug1: ssh_rsa_verify: signature correct

debug1: SSH2_MSG_NEWKEYS sent

debug1: expecting SSH2_MSG_NEWKEYS

debug1: SSH2_MSG_NEWKEYS received

debug1: SSH2_MSG_SERVICE_REQUEST sent

debug1: SSH2_MSG_SERVICE_ACCEPT received

debug1: Authentications that can continue: publickey,password,keyboard-interactive

debug1: Next authentication method: publickey

debug1: Trying private key: /home/username/.ssh/identity

debug1: Trying private key: /home/username/.ssh/id_rsa

debug1: Trying private key: /home/username/.ssh/id_dsa

debug1: Next authentication method: keyboard-interactive

debug1: Authentications that can continue: publickey,password,keyboard-interactive

debug1: Next authentication method: password

username@servername.com's password:

debug1: Authentication succeeded (password).

debug1: fd 4 setting O_NONBLOCK

debug1: fd 5 setting O_NONBLOCK

debug1: channel 0: new [client-session]

debug1: Entering interactive session.

debug1: Sending command: scp -v -f /home/username/tmp/a.txt

debug1: channel 0: request exec

debug1: channel 0: open confirm rwindow 0 rmax 32768

TERM environment variable not set.

protocol error: mtime.sec not delimited

debug1: channel 0: read<=0 rfd 4 len 0

debug1: channel 0: read failed

debug1: channel 0: close_read

debug1: channel 0: input open -> drain

debug1: channel 0: ibuf empty

debug1: channel 0: send eof

debug1: channel 0: input drain -> closed

username@taos tmp $ debug1: channel 0: write failed

debug1: channel 0: close_write

debug1: channel 0: output open -> closed

Sending file modes: C0644 10 a.txt

debug1: channel 0: rcvd eof

debug1: client_input_channel_req: channel 0 rtype exit-status reply 0

debug1: channel 0: rcvd close

debug1: channel 0: almost dead

debug1: channel 0: gc: notify user

debug1: channel 0: gc: user detached

debug1: channel 0: send close

debug1: channel 0: is dead

debug1: channel 0: garbage collecting

debug1: channel_free: channel 0: client-session, nchannels 1

debug1: fd 0 clearing O_NONBLOCK

debug1: fd 1 clearing O_NONBLOCK

debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.2 seconds

debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0

debug1: Exit status 1

```

sshd_config

```

#   $OpenBSD: sshd_config,v 1.59 2002/09/25 11:17:16 markus Exp $

# This is the sshd server system-wide configuration file.  See

# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with

# OpenSSH is to specify options with their default value where

# possible, but leave them commented.  Uncommented options change a

# default value.

#Port 22

#Protocol 2,1

Protocol 2

#ListenAddress 0.0.0.0

#ListenAddress ::

# HostKey for protocol version 1

#HostKey /etc/ssh/ssh_host_key

# HostKeys for protocol version 2

#HostKey /etc/ssh/ssh_host_rsa_key

#HostKey /etc/ssh/ssh_host_dsa_key

#AllowGroups wheel

AllowGroups net

# Lifetime and size of ephemeral version 1 server key

#KeyRegenerationInterval 3600

#ServerKeyBits 768

# Logging

#obsoletes QuietMode and FascistLogging

#SyslogFacility AUTH

#LogLevel INFO

# Authentication:

#LoginGraceTime 120

#PermitRootLogin yes

PermitRootLogin no

#StrictModes yes

#RSAAuthentication yes

#PubkeyAuthentication yes

#AuthorizedKeysFile .ssh/authorized_keys

# rhosts authentication should not be used

#RhostsAuthentication no

RhostsAuthentication no

# Don't read the user's ~/.rhosts and ~/.shosts files

#IgnoreRhosts yes

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts

#RhostsRSAAuthentication no

# similar for protocol version 2

#HostbasedAuthentication no

# Change to yes if you don't trust ~/.ssh/known_hosts for

# RhostsRSAAuthentication and HostbasedAuthentication

#IgnoreUserKnownHosts no

# To disable tunneled clear text passwords, change to no here!

#PasswordAuthentication yes

#PermitEmptyPasswords no

##PasswordAuthentication no

PermitEmptyPasswords no

# Change to no to disable s/key passwords

#ChallengeResponseAuthentication yes

# Kerberos options

#KerberosAuthentication no

#KerberosOrLocalPasswd yes

#KerberosTicketCleanup yes

#AFSTokenPassing no

# Kerberos TGT Passing only works with the AFS kaserver

#KerberosTgtPassing no

# Set this to 'yes' to enable PAM keyboard-interactive authentication

# Warning: enabling this may bypass the setting of 'PasswordAuthentication'

#PAMAuthenticationViaKbdInt no

#X11Forwarding no

#X11DisplayOffset 10

#X11UseLocalhost yes

#PrintMotd yes

#PrintLastLog yes

#KeepAlive yes

#UseLogin no

#UsePrivilegeSeparation yes

#PermitUserEnvironment no

#Compression yes

#MaxStartups 10

# no default banner path

#Banner /some/path

#VerifyReverseMapping no

# override default of no subsystems

Subsystem   sftp    /usr/lib/misc/sftp-server

```

----------

## pintnight

 *shadow255 wrote:*   

>  *pintnight wrote:*    *red_over_blue wrote:*   Can you post the full command you are using for scp? 
> 
> ```
> scp username@servername.com:tmp/a.txt .
> ```
> ...

 

I have tried that and same result.

----------

## pintnight

I have built two computer with gentoo this week.  They both are having the same scp problem.

I used 1.4 rc4 and built from stage1.

----------

## red_over_blue

```

debug1: channel 0: open confirm rwindow 0 rmax 32768

TERM environment variable not set.

protocol error: mtime.sec not delimited 

```

I did a scp -v just to see the output, and it is virtually identical up to this point.  Right after the open confirm rwindow, I receive verification that the file was copied.

One thing that I can think of is this.  If you have some sort of message or funky alarm or something that is activated every time you log in, ala "Hi Dave, glad you decided to log in today", this can screw up scp.  Do you have anything like this in .bashrc or something?

----------

## pintnight

 *red_over_blue wrote:*   

> 
> 
> ```
> 
> debug1: channel 0: open confirm rwindow 0 rmax 32768
> ...

 

Ah!! That was the problem.  I had added these to .bashrc

```

TERM=vt100

clear

forrtune

echo ""

```

I have now moved those to .bash_profile and scp is now working!!

Thanks for the clue.

----------

## red_over_blue

Just glad it was something simple to fix  :Smile: 

----------

## tucolino

old thread, but thanks anyway... this was buggin' me for a while and could not figure out why it was happening... 

later, 

tuco

----------

