How do I automatically backup remote files after connecting via Putty or SSH?
Vim doesn't seem to create backup locally for those files...
Below is the setting for my vimrc
set backup
set backupdir=~/backup/
set dir=~/backup/
It works for my local files by the way.
If you use vim on the remote machine, you have to also set the settings there. You should copy your .vimrc to the other machine. One easy way for this is scp ~/.vimrc user#server:~
Related
I have an ssh connection to a remote machine in my terminal window, and GVim running locally as my text editor. I can mount the remote machine via SSH and open files in my local Vim. I can also edit remote files in my local Vim via Vim's support for editing over SCP.
Say I then use ag on the remote machine to search my project for a symbol:
[user#remote project]$ ag thingy
include/blah/foo.h
1137:void thingy() {
Now what can I type inside my SSH session to send that file to my local editor in a tab? If I were on my local machine, I could do something like gvim -p --remote-tab-silent include/blah/foo.h, but I don't think the Vim +clientserver Remote system can be forwarded over an SSH session, can it? Would it somehow magically work if I set up X11 forwarding? If so, how would Vim work out what remote server to connect to to edit the file? Is there maybe some kind of integration between a vim-embedded terminal session and the netrw system that I could use instead?
If I wanted to roll my own system with shell scripts and netcat and forwarding sockets of some kind over ssh, how might I design that?
The +clientserver mechanism on Linux and Unix systems uses X11:
The communication between client and server goes through the X server. The
display of the Vim server must be specified. The usual protection of the X
server is used, you must be able to open a window on the X server for the
communication to work. It is possible to communicate between different
systems.
If you set up X forwarding properly, you should be able to open the file, although I haven't tested. That means that the remote system should have a $DISPLAY environment variable.
If you haven't specified the server name explicitly, it is usually in the title bar of the window. The first one, on my Debian system, is GVIM, the next is GVIM2, etc. Client/server arguments need to go on the command line in a specific order and first on the command line. I'd try setting this up on a local machine and only then trying it with the remote machine.
To work remotely I need to SSH into the main server and then again into the departmental server.
I would like to set up a tunnel using sublime text 3 wbond sftp package to view and edit files remotely but I can't seem to find any information for setting up a tunnel. Is this even possible?
The reason I'm interested in this particular package is because I am unable to install any packages locally on the server, hence using something like rsub is not possible.
Any other suggestions besides sublime sftp are welcome.
I'm not sure the SFTP plugin would allow to do this directly.
What i would suggest is for you to use ssh -L to create a tunnel.
ssh -L localhost:random_unused_port:target_server:22 username_for_middle_server#middle_server -nNT
Use the password/identity_file for the middle server
The -nNT is to avoid opening an interactive shell in the middle server.
IMPORTANT: You need to keep the ssh -L command running so keep that shell open.
In this way you can connect to the target_server as such:
ssh username_for_target_server#localhost -p random_port_you_allocated
Similarly you can setup the SFTP plugin file as such
{
...
"host":"localhost",
"user":"username_for_target_server",
"ssh_key_file": "path_to_target_server_key",
"port":"random_port_you_allocated",
....
}
As a sidenote, always use the same port to tunnel to the same server, otherwise, with the default ssh configuration, you will be warned of a "Man in the middle attack" because the signature saved in the .ssh/known_hosts will not match with the previous one. This can be avoided by disabling this feature but I wouldn't recommend it.
I need to ssh to remote machine and edit in vim. Sometimes, I need to copy some back from the
remote machine to local machine. Is there any easy way to do it?
What I want like this:
remote: select a few lines in vim, and yank it in a register or something.
local: put the content from remote machine into a local buffer.
you can open the remote file in your local vim(via scp), e.g.:
vim scp://youruser#remoteserver//path/to/yourfile
My current use pattern of emacs results in my having several shell-mode buffers open, each running an ssh session. I am running into an issue with this, though - when I try to tab-complete file names and other things in my remote session, the shell attempts to use completions available on the local machine instead of on the remote machine.
For example, if the file ~/foobar exists on the local machine and ~/frob exists on the remote machine, typing in ~/f and pressing tab results in ~/foobar instead of completing correctly. If I use ssh outside of emacs and try the same thing, I get the correct completion of ~/frob instead.
How can I get tab-completion to complete the way it does in normal ssh sessions ?
Later note: M-x cd RET /ssh:host.example.com:/path/to/me also seems to nudge it into being able to gracefully deal with tab completion.
Instead of running M-x shell and running ssh to the remote computer, visit a directory on the remote computer (using Tramp) and then run M-x shell in that Dired buffer.
Emacs can't track the current directory (default-directory) when ssh-ing to other machines.
You could set default-directory to a tramp file-name like /ssh:YOURHOST:/home/dir" on your current shell-buffer manually.
I start shell-sessions on a remote machine mostly via tramp-bookmarks/shell. Tramp sets default-directory automatically.
But there is a bug in directory tracking on remote files, which is fixed in trunk (unreleased).
http://comments.gmane.org/gmane.emacs.bugs/39082
i am new vim user
i cannot create file in my host by vim
i use :ftp://user#machine/path
i can connect in my host but i cannot create new file ???
another Q
when i open file how i can back in directory
note. i connect by c panel user and password ,, how i can connect by ftp username and password
thank you and Sorry for my bad English
You can access your remote file in Vim by typing:
vim ftp://user#machine/path/filename
in your command line.
Some things you might want to consider:
If you are using a Unix-like OS on your client machine, you'll probably find it easiest to simply mount your FTP site to a local directory, and then create and edit your files with whatever you like, for example Vim.
As one user suggested, if the host is Unix-like you can connect it via SSH and then edit files with Vim installed over there.