LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Copying through ssh from localhost to on-line linux server (https://www.linuxquestions.org/questions/linux-server-73/copying-through-ssh-from-localhost-to-on-line-linux-server-932804/)

fortran 03-05-2012 07:15 AM

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.

acid_kewpie 03-05-2012 07:19 AM

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.

fortran 03-05-2012 07:35 AM

Quote:

Originally Posted by acid_kewpie (Post 4618864)
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.

roberto967 03-05-2012 07:38 AM

have you considered using sshfs?

Quote:

Originally Posted by pavi_kanetkar (Post 4618860)
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.


acid_kewpie 03-05-2012 07:42 AM

Quote:

Originally Posted by roberto967 (Post 4618871)
have you considered using sshfs?

How would that help at all? If scp doesn't work, clearly sshfs will fail just as readily.

acid_kewpie 03-05-2012 07:44 AM

Quote:

Originally Posted by pavi_kanetkar (Post 4618869)
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?

saifelyzal 03-05-2012 10:11 PM

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

elfenlied 03-06-2012 12:03 AM

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.

fortran 03-07-2012 12:01 AM

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.


All times are GMT -5. The time now is 01:58 PM.