[SOLVED] Copying through ssh from localhost to on-line linux server
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
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...
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...
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.
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.
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...
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...
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?
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
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:
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:
@ 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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.