LinuxQuestions.org
Visit Jeremy's Blog.
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 03-05-2012, 07:15 AM   #1
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Copying through ssh from localhost to on-line linux server


I have .pem file of a Linux server so through .pem I can access that linux server.
I am using ubuntu operating system, localhost is installed on ubuntu.
I am logged in already there using...
Code:
ssh -i that-pem-file.pem username@abx-xxx-xxx-xxx-xxx-anotherword1.otherword.com
Now I have reached into that server location. I do not have username - password of root or this username from which I am accessing linux server.
I want to copy the files from my localhost to this linux server and vice-versa. I have tried this command.
As I am logged into linux server already so I have tried...
Code:
[username@ip-xx-xxx-xxx-xxx tmp]$ scp -r /tmp/lampp/lampp root@192.168.0.140:/root/Desktop
but it says
Code:
ssh: connect to host 192.168.0.140 port 22: Connection timed out
lost connection
please suggest better solution.
 
Old 03-05-2012, 07:19 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
where is this box you're trying to copy files to? Looks like a basic network issue, or SSH is not running. How does your first ssh command relate to your situation? You clearly have a totally different user / host being used. Is this information irrelevant?

I would say there is no "better" solution, as scp is absolutely ideal, but if the network won't allow it, or there is no ssh service to connect to, clearly that's not going to work.
 
Old 03-05-2012, 07:35 AM   #3
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300

Original Poster
Blog Entries: 2

Rep: Reputation: 51
Quote:
Originally Posted by acid_kewpie View Post
where is this box you're trying to copy files to? Looks like a basic network issue, or SSH is not running. How does your first ssh command relate to your situation? You clearly have a totally different user / host being used. Is this information irrelevant?
I would say there is no "better" solution, as scp is absolutely ideal, but if the network won't allow it, or there is no ssh service to connect to, clearly that's not going to work.
ssh is installed on both places, my machine as well as that Linux server. I can copy on my machine (one place to another)using scp & that Linux server (one place to another)using scp but I am not able to copy from my local-machine to that Linux server.
 
Old 03-05-2012, 07:38 AM   #4
roberto967
Member
 
Registered: Apr 2011
Location: Cagliari, Italy
Distribution: Slackware64-15.0 multilib
Posts: 116

Rep: Reputation: 35
have you considered using sshfs?

Quote:
Originally Posted by pavi_kanetkar View Post
I have .pem file of a Linux server so through .pem I can access that linux server.
I am using ubuntu operating system, localhost is installed on ubuntu.
I am logged in already there using...
Code:
ssh -i that-pem-file.pem username@abx-xxx-xxx-xxx-xxx-anotherword1.otherword.com
Now I have reached into that server location. I do not have username - password of root or this username from which I am accessing linux server.
I want to copy the files from my localhost to this linux server and vice-versa. I have tried this command.
As I am logged into linux server already so I have tried...
Code:
[username@ip-xx-xxx-xxx-xxx tmp]$ scp -r /tmp/lampp/lampp root@192.168.0.140:/root/Desktop
but it says
Code:
ssh: connect to host 192.168.0.140 port 22: Connection timed out
lost connection
please suggest better solution.
 
Old 03-05-2012, 07:42 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Quote:
Originally Posted by roberto967 View Post
have you considered using sshfs?
How would that help at all? If scp doesn't work, clearly sshfs will fail just as readily.
 
Old 03-05-2012, 07:44 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Quote:
Originally Posted by pavi_kanetkar View Post
ssh is installed on both places, my machine as well as that Linux server. I can copy on my machine (one place to another)using scp & that Linux server (one place to another)using scp but I am not able to copy from my local-machine to that Linux server.
really not sure what sort of architecture you're dealing with at all... but you did say "my local-machine" as if the other machine is NOT local?? So that's a private IP address you're using, so has no chance if you're trying to connect over the internet. Maybe you would benefit from describing your network in some detail?
 
Old 03-05-2012, 10:11 PM   #7
saifelyzal
LQ Newbie
 
Registered: Jun 2011
Distribution: Redhat
Posts: 28

Rep: Reputation: Disabled
as long you be able to connect to the remote host you should be able copy file to the remote server but you need to check if you have right permissions.
and to copy file from the remote server to your local machine you need to forward sshd port on your router because as you describe your example you using un routable ip address
 
Old 03-06-2012, 12:03 AM   #8
elfenlied
Member
 
Registered: Dec 2004
Posts: 83

Rep: Reputation: 8
I would use scp to copy files to and from the server. You don't need to login to the server first to copy files to it, what you are trying to do from the server won't work because you are trying to connect to your local ip address which the server won't know anything about.

To a file to the server use something like this, from a terminal on your localhost:

Code:
scp -i that-pem-file.pem <file_to_copy> username@abx-xxx-xxx-xxx-xxx-anotherword1.otherword.com:~
That will copy a file to the home directory on the remote server. To copy a file from the remote server to your localhost (you need to know the exact path) do this:

Code:
scp -i that-pem-file.pem username@abx-xxx-xxx-xxx-xxx-anotherword1.otherword.com:~/<file_to_copy> .
That will copy a file from within your home directory on the remote server to your current directory on your localhost.
 
Old 03-07-2012, 12:01 AM   #9
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300

Original Poster
Blog Entries: 2

Rep: Reputation: 51
Code:
scp -i that-pem-file.pem <file_to_copy> username@abx-xxx-xxx-xxx-xxx-anotherword1.otherword.com:~
Code:
scp -i that-pem-file.pem username@abx-xxx-xxx-xxx-xxx-anotherword1.otherword.com:~/<file_to_copy> .
@ elfenlied
Thanks for giving me this wonderful solution. That's what I was asking. Now I am able to copy the files on server direct from my local host. The server is not able to know my local host's address because in every LAN, there can be 192.168.0.140 so how the server can know about my location. That's why I asked this question. and your solution is perfect.
The file is copied to exact location on server where I want. Now I can move into whatever directory.
& it works vice-versa too
Thank you very much for giving me this solution.
& Thanks to linuxquestions.org too.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
ssh command line copying from linux to smb share fails due to security florenceit Linux - Networking 3 08-28-2010 09:18 PM
copying files from remote server through ssh dave247 Debian 12 11-21-2008 09:56 AM
How to start SSH server from cmd line? kc5hwb Ubuntu 5 04-11-2007 06:27 PM
Copying .ssh from one server to another xpucto Linux - Newbie 2 07-03-2006 04:52 AM

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

All times are GMT -5. The time now is 09:57 AM.

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