LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-21-2012, 05:12 AM   #1
ravishankaradepu
LQ Newbie
 
Registered: Dec 2011
Posts: 15

Rep: Reputation: Disabled
SSH working but SCP not working


Hi,
i have implemented Password-less ssh to my server.
Now i can ssh to my server but i cant do scp to my server.
But i can scp from my server machine to client
 
Old 05-21-2012, 08:56 AM   #2
blue_print
Member
 
Registered: May 2010
Location: In world
Distribution: RHEL, CentOS, Ubuntu
Posts: 275
Blog Entries: 3

Rep: Reputation: 50
Have you set password-less SSH from client to server? If so, password-less SSH from client to server is working?
 
Old 05-21-2012, 10:15 AM   #3
ravishankaradepu
LQ Newbie
 
Registered: Dec 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by blue_print View Post
Have you set password-less SSH from client to server? If so, password-less SSH from client to server is working?
I have set passwordless ssh from client to server.
Now ssh is working from client to server but scp is not working
 
Old 05-21-2012, 10:38 AM   #4
blue_print
Member
 
Registered: May 2010
Location: In world
Distribution: RHEL, CentOS, Ubuntu
Posts: 275
Blog Entries: 3

Rep: Reputation: 50
Can you please paste the ssh and scp commands you're trying?
 
Old 05-21-2012, 10:26 PM   #5
ravishankaradepu
LQ Newbie
 
Registered: Dec 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by blue_print View Post
Can you please paste the ssh and scp commands you're trying?
ravishankaradepu@ravishankaradepu-CELSIUS-M470-2:~$ ssh -v printer@192.168.4.151
OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.4.151 [192.168.4.151] port 22.
debug1: Connection established.
debug1: identity file /home/ravishankaradepu/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/ravishankaradepu/.ssh/id_rsa-cert type -1
debug1: identity file /home/ravishankaradepu/.ssh/id_dsa type -1
debug1: identity file /home/ravishankaradepu/.ssh/id_dsa-cert type -1
debug1: identity file /home/ravishankaradepu/.ssh/id_ecdsa type -1
debug1: identity file /home/ravishankaradepu/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-4ubuntu6
debug1: match: OpenSSH_5.5p1 Debian-4ubuntu6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-1ubuntu3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) 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: Server host key: RSA 52:7c:ec:27:16:f0:d7:5c:1c:56:b6:a8:79:d7:c1:e4
debug1: Host '192.168.4.151' is known and matches the RSA host key.
debug1: Found key in /home/ravishankaradepu/.ssh/known_hosts:9
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/ravishankaradepu/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.4.151 ([192.168.4.151]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Remote: Forced command: /usr/local/sbin/log-session
debug1: Remote: Forced command: /usr/local/sbin/log-session
debug1: Sending environment.
debug1: Sending env LC_MESSAGES = en_IN.UTF-8
debug1: Sending env LANG = en_IN
printer@printer-CELSIUS-M470-2:~$


ravishankaradepu@ravishankaradepu-CELSIUS-M470-2:~$ scp -v My_cv.doc printer@192.168.4.151:.
Executing: program /usr/bin/ssh host 192.168.4.151, user printer, command scp -v -t -- .
OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.4.151 [192.168.4.151] port 22.
debug1: Connection established.
debug1: identity file /home/ravishankaradepu/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/ravishankaradepu/.ssh/id_rsa-cert type -1
debug1: identity file /home/ravishankaradepu/.ssh/id_dsa type -1
debug1: identity file /home/ravishankaradepu/.ssh/id_dsa-cert type -1
debug1: identity file /home/ravishankaradepu/.ssh/id_ecdsa type -1
debug1: identity file /home/ravishankaradepu/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-4ubuntu6
debug1: match: OpenSSH_5.5p1 Debian-4ubuntu6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-1ubuntu3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) 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: Server host key: RSA 52:7c:ec:27:16:f0:d7:5c:1c:56:b6:a8:79:d7:c1:e4
debug1: Host '192.168.4.151' is known and matches the RSA host key.
debug1: Found key in /home/ravishankaradepu/.ssh/known_hosts:9
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/ravishankaradepu/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.4.151 ([192.168.4.151]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Remote: Forced command: /usr/local/sbin/log-session
debug1: Remote: Forced command: /usr/local/sbin/log-session
debug1: Sending environment.
debug1: Sending env LC_MESSAGES = en_IN.UTF-8
debug1: Sending env LANG = en_IN
debug1: Sending command: scp -v -t -- .
Sending file modes: C0644 28672 My_cv.doc
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2752, received 2408 bytes, in 0.2 seconds
Bytes per second: sent 15039.6, received 13159.6
debug1: Exit status 0
lost connection
 
Old 05-22-2012, 01:43 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
it looks like a problem on the other side. Probably scp cannot write the file or ??? Can you check the logs on that host also?
 
Old 05-22-2012, 03:22 AM   #7
ravishankaradepu
LQ Newbie
 
Registered: Dec 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
it looks like a problem on the other side. Probably scp cannot write the file or ??? Can you check the logs on that host also?
I checked /var/log/syslog but it dosent have anything there...!!
 
Old 05-22-2012, 04:09 AM   #8
ravishankaradepu
LQ Newbie
 
Registered: Dec 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ravishankaradepu View Post
I checked /var/log/syslog but it dosent have anything there...!!
I got the problem
When ever i am ssh using password less ssh , i use forced command to store the session to a file. I use the following script to do that.
Now what should i do to do this for scp also??

#!/bin/sh
#
# log-session
# John Simpson <jms1@jms1.net> 2008-08-06
#
###############################################################################
#
# Copyright (C) 2008 John Simpson.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# configuration

# copy this value from the "Subsystem sftp" line in your sshd_config file
SFTP_SERVER=/usr/lib/openssh/sftp-server

###############################################################################
###############################################################################
###############################################################################

NOW=`date +%Y-%m-%d.%H%M%S`
IP=`echo $SSH_CLIENT | sed 's/ .*//'`
#LOGFILE=/root/.ssh/log.$NOW.$IP
LOGFILE=/home/printer/.ssh/log.$NOW.$IP
# if you want to log the initial contents of the environment received from
# sshd, un-comment these lines.
#
# env | sort >> $LOGFILE
# echo "========================================" >> $LOGFILE

# the "internal-sftp" service is new as of openssh 5.0. it works like
# the sftp server logic is built into sshd, and as such it's capable of
# chroot'ing users into their home directories.
# there's no way to "redirect" execution back into it, so the best we
# can do is exec the old sftp-server instead, which will give the user a
# working sftp session, but won't chroot them into their home directory.

if [ "${SSH_ORIGINAL_COMMAND:-}" = "internal-sftp" ]
then
echo "substituting $SFTP_SERVER for internal SFTP service" >> $LOGFILE
echo "========================================" >> $LOGFILE
exec $SFTP_SERVER

# if they're requesting the sftp server, this is an sftp command.
# logging the traffic wouldn't make much sense, it's a binary protocol...
# although if you really want to log the raw data, comment out this block
# and let execution fall through to the next block.

elif [ "${SSH_ORIGINAL_COMMAND:-}" = "$SFTP_SERVER" ]
then
echo starting SFTP service >> $LOGFILE
echo ======================================== >> $LOGFILE
exec $SFTP_SERVER

# if the user asked for a specific command, run that command
# but log the traffic going into and out of it.

elif [ -n "${SSH_ORIGINAL_COMMAND:-}" ]
then
echo executing $SSH_ORIGINAL_COMMAND >> $LOGFILE
echo ======================================== >> $LOGFILE
exec script -a -f -q -c "$SSH_ORIGINAL_COMMAND" $LOGFILE

# no command was requested, user wants an interactive shell.
# of course, log the traffic going in and out of it.

else
echo starting interactive shell session >> $LOGFILE
echo ======================================== >> $LOGFILE
exec script -a -f -q $LOGFILE
fi

# if we get to this point, an "exec" failed somewhere.

echo exec failed, rv=$?
exit 1
 
Old 05-22-2012, 04:14 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
what I see is: scp looks for authentication in /home/ravishankaradepu but it wants to write into the home of printer. Try to execute
scp My_cv.doc printer@192.168.4.151:/tmp, use full path, instead of .
 
Old 05-22-2012, 04:18 AM   #10
ravishankaradepu
LQ Newbie
 
Registered: Dec 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
what I see is: scp looks for authentication in /home/ravishankaradepu but it wants to write into the home of printer. Try to execute
scp My_cv.doc printer@192.168.4.151:/tmp, use full path, instead of .
Same Lost connection is being outputted
 
Old 05-22-2012, 04:26 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Oh yes, that can be a problem also. this log-session started by scp also, you can see it in the debug log. This shell script will write log to /home/printer/.ssh/log.$NOW.$IP. You can check the content.
 
1 members found this post helpful.
Old 05-22-2012, 04:35 AM   #12
ravishankaradepu
LQ Newbie
 
Registered: Dec 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
Oh yes, that can be a problem also. this log-session started by scp also, you can see it in the debug log. This shell script will write log to /home/printer/.ssh/log.$NOW.$IP. You can check the content.
What changes should be done to the log-session ??
 
Old 05-22-2012, 04:40 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
I do not know what's happened, so would be better to see the log
 
1 members found this post helpful.
Old 05-22-2012, 04:41 AM   #14
ravishankaradepu
LQ Newbie
 
Registered: Dec 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I do not know what's happened, so would be better to see the log
One line was written to the file , but it was not readable
 
Old 05-22-2012, 05:46 AM   #15
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
you can insert a line into that log-session script:
Code:
#!/bin/sh
set -xv           # <== insert this line
#
# log-session
# John Simpson <jms1@jms1.net> 2008-08-06
and test it again. That one line is not an acceptable result.
Also you can try to move it:
LOGFILE=/tmp/sshlog.$NOW.$IP
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ssh scp key not working to ssh/scp without password anon091 Linux - Newbie 9 08-22-2011 04:28 PM
SCP command is not working properly due to SSH enabled musammil123 Linux - Server 1 05-27-2011 03:57 PM
Chroot SSH problem: ssh working, not SFTP & SCP. NaCo Linux - Security 3 02-01-2009 02:23 AM
ssh/scp without password not working Mauline Linux - Security 4 03-30-2005 09:26 PM
ssh working, but not sftp scp hardigunawan Linux - Networking 2 05-02-2003 02:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration