Reputation: 1425
I followed some of the solutions here on stackoverflow, and almost each one of them has different solution from the other. I am trying to copy the entire content of a file on remote sever by doing:
vi file1
once inside the file I am doing:
:%y
That returns "1200 lines yanked "
Then I go to my another vi file on my local machine. I do:
vi file2
Then I tried pasting using ctrl p
, ctrl R
inside the empty vi file and many other commands it didn't work.
I even tried cat dump.sql | xclip
. That didn't either. I am running ubuntu 14.04. can somebody please tell me how to achieve this Copy all and paste thing??
Upvotes: 0
Views: 354
Reputation: 1425
Many of these answers didn't work for me. I don't know if I got the syntax wrong or something. It was confusing for me. Here is what I did. I will put it in a very clear way.
First make sure you can ssh into your server. For that copy your local /.ssh/id_rsa.pub and paste it on your ec2 instance /.ssh/authorized_keys. So now try ssh into your server like ssh <your ubuntu user>@<ec2_public_ip>
. If you were able to login to your server you are good for next step.
Find the path of the filename you want to download by doing this:
find "$(cd ..; pwd)" -name "filename"
You'll get the path. Copy that path. Next
Type this: On your local system
-$ scp ssh <your ubuntu user>@<your ec2 ip>:<the path you copied> <and the path on your local to download>
This will do it for you. I hope this is clear for if any rookie like myself gets stuck next time.
Upvotes: 0
Reputation: 1313
The way -I do this- (open to improvements!), is by scp-ing the file from within vim.
From shell:
Then within vim:
For the scp:// solution recommended by nzajt, it seems one has to enable these (based on the link he provided):
- Enable X11Forwarding on the SSH server side in /etc/ssh/sshd.conf
- Use the -Y option for ssh client to enable it when connecting: ssh -Y your_server
I was unable to get the scp:// solution to work.
Upvotes: 0
Reputation: 1985
When you ssh into a server and use vim you are using the server's vim not your vim.
There isn't anything wrong with your vim or the server's vim.
if you are looking to copy an entire file I would just use scp to pull the file down to your computer.
as @ Meninx - メネンックス said you could try something like this :e scp://user@host/relative/path/from/home.txt
if you wanted to do the entire operation in your vim.
The above code is from Vim: access to system clipboard via ssh - Linux to OS X
Upvotes: 1