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 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 Code:
ssh: connect to host 192.168.0.140 port 22: Connection timed out |
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. |
Quote:
|
have you considered using sshfs?
Quote:
|
Quote:
|
Quote:
|
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: 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> . |
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> . 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. |