rcp Vs rsync prompting for password - linux

This might be a repeat question but exact explanation I am not getting. I am new to LINUX environment.
I was trying to copy files from one system to other system. If I issue rcp command it copies without asking for password but if I issue rsync command then it asking for permission. Can you please explain why?

rcp is an ancient and insecure program for copying files between remote machines. Avoid it. scp (of the ssh suite) is the secure, modern alternative.
rsync is a relatively recent program. When connecting remotely, it uses ssh in the background which, being secure, is what is asking for credentials.

Related

How to copy files on remote Windows to local Linux on a Linux machine?

Currently, I'm working on a local Linux machine. I'm trying to use scp or similar Linux command-line tools to copy files from a remote Windows machine to my local Linux. I did some searching and found that most of the solutions are for local Windows cases (like putty and winscp), which don't really help.
Please advise.Thank you.
[UPDATE] Solved by installing cygwin's sshd service on Windows.
If you really want to use SCP, you will need an SCP server (actually an SSH server) on the Windows machine.
For example freeSSHd.
You will need to choose one of the options based on your own needs, there are a number of similar tools and freeSSHd was the first in the list on Google. I've used the Bitvise SSH Server in the past but it is only free for non-commercial use.
They are usually very easy to set up. You install them the usual way and run them for the first time. Depending on the tool, they may pick up your existing Windows users or you may need to manually create some users with passwords within the tool. Then, armed with your PC's IP address, you should be able to connect to the PC using SSH from the Linux command line.
If the windows system has a shared folder you should be able access that with smbclient which is part of the terrific samba project.
Usually somthing like:
smbclient //winmachine/share
Possibly using the -U username options to specifiy the username on the windows box.
Once connected, you can use cd to change folders, and get to retrieve files.
If there is no file share.... I dunno. Create one?
Syntax for copying from remote Windows 10 machine with built-in SSH server. Note forward slashes and drive style. Domain is not necessary.
scp user#domain#example.com:c:/path/to/file.txt .

How to copy a file from my local disk to remote applicatin in Unix

Let's say I have created XML file inside C:/path/MyFolder/MyFile.xml. I want to copy them to my remote account in a Unix machine. ~/Home/www.
I read the tutorial, no where I see where I can copy or move file from my local to the remote system.
scp is a good suggestion, but for beginners i recommend sftp with a graphical client, like winscp or filezilla.
http://winscp.net/eng/index.php
https://filezilla-project.org/
I would use scp to send files to remote machines. For example:
scp C:/path/MyFolder/MyFile.xml user#remoteBox:/home/www/MyFile.xml
A common way to do this is scp (secure copy). A famous client ist putty.
Just google it ;) Of course, on the unix machine you must install a ssh-server (very often in the official repository).
You can use ftp or scp.
Maybe, from a Windows host you can easily use filezilla to do so. It's a very intuitive program.

Remotely Programming

I'm doing my development work on my Windows machine, but my compiling on a remote Linux machine. What I currently do is start an X server on Windows, ssh into the Linux machine, then do the development remotely.
What I'd like to do is edit my source on the Windows machine, and have it automatically copy files over to the Linux system when I save. I'd also like for my built-in compilation commands to perform a build on the remote system.
If it makes a difference, the source is all in C, using GCC. In descending order of preference, I have Emacs, Vi, and Netbeans on my desktop, and am willing to install another IDE for a last resort.
This is certainly doable in vim. You can use the scp:// protocol within vim to edit remote files, and set up a command that writes a local copy. You can also change what program vim uses for :make to do an ssh make instead on your server.
You'll need to set up your ssh-keys to keep this painless (otherwise you'll be entering your password all the time) but that's fairly easy.
Another alternative would be to push to a remote repos as part of your make command, instead of editing remotely.
EDIT:
First, using the scp:// protocol within vim. From :help netrw-start (or down the page from :help scp)
Netrw supports "transparent" editing of files on other machines using urls
(see |netrw-transparent|). As an example of this, let's assume you have an
account on some other machine; if you can use scp, try:
vim scp://hostname/path/to/file
Want to make ssh/scp easier to use? Check out |netrw-ssh-hack|!
You can also use scp:// paths in :edit commands, or really anywhere that you could use a normal path.
And, from the mentioned :help netrw-ssh-hack, instructions on how to set up your ssh keys:
IMPROVING BROWSING *netrw-listhack* *netrw-ssh-hack* {{{2
Especially with the remote directory browser, constantly entering the password
is tedious.
For Linux/Unix systems, the book "Linux Server Hacks - 100 industrial strength
tips & tools" by Rob Flickenger (O'Reilly, ISBN 0-596-00461-3) gives a tip
for setting up no-password ssh and scp and discusses associated security
issues. It used to be available at http://hacks.oreilly.com/pub/h/66 ,
but apparently that address is now being redirected to some "hackzine".
I'll attempt a summary based on that article and on a communication from
Ben Schmidt:
(1) Generate a public/private key pair on the local machine
(ssh client):
ssh-keygen -t rsa
(saving the file in ~/.ssh/id_rsa as prompted)
(2) Just hit the when asked for passphrase (twice) for no
passphrase. If you do use a passphrase, you will also need to use
ssh-agent so you only have to type the passphrase once per session.
If you don't use a passphrase, simply logging onto your local
computer or getting access to the keyfile in any way will suffice
to access any ssh servers which have that key authorized for login.
(3) This creates two files:
~/.ssh/id\_rsa
~/.ssh/id\_rsa.pub
(4) On the target machine (ssh server):
cd
mkdir -p .ssh
chmod 0700 .ssh
(5) On your local machine (ssh client): (one line)
ssh {serverhostname} cat '>>' '~/.ssh/authorized\_keys2' < ~/.ssh/id_rsa.pub
or, for OpenSSH, (one line)
ssh {serverhostname} cat '>>' '~/.ssh/authorized\_keys' < ~/.ssh/id_rsa.pub
You can test it out with
ssh {serverhostname}
and you should be log onto the server machine without further need to type
anything.
If you decided to use a passphrase, do:
ssh-agent $SHELL
ssh-add
ssh {serverhostname}
You will be prompted for your key passphrase when you use ssh-add, but not
subsequently when you use ssh. For use with vim, you can use
ssh-agent vim
and, when next within vim, use
:!ssh-add
Alternatively, you can apply ssh-agent to the terminal you're planning on
running vim in:
ssh-agent xterm &
and do ssh-add whenever you need.
For Windows, folks on the vim mailing list have mentioned that Pageant helps
with avoiding the constant need to enter the password.
Kingston Fung wrote about another way to avoid constantly needing to enter
passwords:
In order to avoid the need to type in the password for scp each time, you
provide a hack in the docs to set up a non password ssh account. I found a
better way to do that: I can use a regular ssh account which uses a
password to access the material without the need to key-in the password
each time. It's good for security and convenience. I tried ssh public key
authorization + ssh-agent, implementing this, and it works! Here are two
links with instructions:
http://www.ibm.com/developerworks/library/l-keyc2/
http://sial.org/howto/openssh/publickey-auth/
For making on remote systems, you need to set your makeprg variable to
do an ssh make. From :help makeprg
Program to use for the ":make" command. See |:make_makeprg|.
This option may contain '%' and '#' characters, which are expanded to
the current and alternate file name. |:_%| |:_#|
Environment variables are expanded |:set_env|. See |option-backslash|
about including spaces and backslashes.
Note that a '|' must be escaped twice: once for ":set" and once for
the interpretation of a command. When you use a filter called
"myfilter" do it like this:
:set makeprg=gmake\ \\\|\ myfilter
The placeholder "$*" can be given (even multiple times) to specify
where the arguments will be included, for example:
:set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*}
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
One option is to use the TRAMP remote-editing package (built into Emacs 22 and newer, and you can install it into older versions). Every time you save your file, Emacs sends its contents over ssh (by default; of course every detail is totally configurable) to the Linux machine. Commands like M-x compile and M-x grep are TRAMP-aware and execute on the remote host.
I would look into continuous integration for your environment. This way you can commit the changes to source control, and have the linux box act as a build server. You can have tests associated and other related interesting stuff you want to be run on the builds.
Update 1: Also this might work for you: http://metamod-p.sourceforge.net/cross-compiling.on.windows.for.linux.html (it is also worth a try doing some searches on similar tools)
Other have suggested SAMBA which may not be feasible on your Linux box. A good alternative is to use Dokan SSHFS on your Windows box to mount a remote directory over SSH.
You could try sharing a disk between your Linux and Windows machines using Samba or something like that. Then you could edit on your local machines and the files would be visible immediately on the remote machine since the drive would be visible to both.
Where I work we have all files on NFS that is accessible from all Linux machines and Windows machines. I don't know how hard it is to set that up since I work in a large corporation and IT is abstracted away from me, but simple disk sharing should be pretty straightforward.
Why do you start an X server on Windows? Personally, I would set up a Linux VM with VMware or whatever your favorite VM technology is (VMware is free and works well). Then choose any Linux distribution you want. You just need very basic functions, mostly the standard "toolchain." You could pick Centos, Ubuntu, Fedora, Debian, whatever. I usually use Centos or Debian. Set it up, and just use PuTTY into your VM. From there, you can scp files to your remote server and so forth. This way you don't have to bother with cygwin or an X server or any of that.
Can you just use a samba share to save the files directly on the remote machine? I often do PHP this way.
Then just have a putty window open to run commands on the remote box.
Or am I missing something?
Set a source control system and use it. Then you can just make a commit after saving in your IDE, and on server you can have something happening on-commit.
This can trigger tests, build, mail any errors to you...
One solution might be to have some sort of polling app that checks the timestamp on the files to see if they have changed. If they have then get it to save and then compile. Kinda hackish this way but it would be workable.
I personally use XMing with PuTTY. I ssh using PuTTY while XMing is running. I can open up any editor (gvim, emacs, gedit, etc) and it will appear.
You will need to do some setup on PuTTY though:
Expand Connection
Expand SSH
Click on X11
Check the "Enable X11 Forwarding"
In the text field for display location, enter (without quotes): "localhost:0"
Save session and connect.

How do I mount a remote Linux folder in Windows through SSH? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm a blind student currently in a system admin/shell programming class. Although ssh works fine for executing commands like ls, pwd, etc editors do not work well with my screen reader and an ssh session. I was wondering if it is possible to mount a Linux folder over ssh so it appears as a windows drive? This way I could edit any files I needed to with accessible software and not have to constantly use SCP to send files back and fourth.
Back in 2002, Novell developed some software called NetDrive that can map a WebDAV, FTP, SFTP, etc. share to a windows drive letter. It is now abandonware, so it's no longer maintained (and not available on the Novell website), but it's free to use. I found quite a few available to download by searching for "netdrive.exe" I actually downloaded a few and compared their md5sums to make sure that I was getting a common (and hopefully safe) version.
Update 10 Nov 2017
SFTPNetDrive is the current project from the original netdrive project. And they made it free for personal use:
We Made SFTP Net Drive FREE for Personal Use
They have paid options as well on the website.
Dokan looks like a FUSE and sshfs implementation for Windows. If it works as expected and advertised, it would do exactly what you are looking for.
(Link updated and working 2015-10-15)
The best an easiest solution I found is https://github.com/billziss-gh/sshfs-win, connected servers shows up as a fully functioning network drives. This is not a 'Dokany' or 'dokan' based solution which from experiance seems more stable and performant, also see WinFsp Performance Testing.
Please note previously this answer stated, https://github.com/Foreveryone-cz/win-sshfs and before that http://www.swish-sftp.org/ but I no longer use any of them, first one stopped working second one created drives not fully supported in all programs.
Another, more Windows-y option (for $39) is http://www.expandrive.com/sftpdrive
Take a look at CIFS (http://www.samba.org/cifs/). It is a virtual file system you can run on your linux machine that will allow you to mount folders on your linux machine in windows using SMB.
CIFS on linux information can be found here: http://linux-cifs.samba.org/
You need to mount a remote share on your windows machine. This is what Samba/smb is for.
What you'll be doing is turning your Linux box into an SMB server, which lets it share files in a way that plays nice with Windows.
If you're not on the same network, you'll need to tunnel this through your SSH connection which may not be worth the effort.
check out Dokan
https://dokan-dev.github.io/
it's iffy, but it works, and it's free
I don't think you can mount a Linux folder as a network drive under windows having only access to ssh. I can suggest you to use WinSCP that allows you to transfer file through ssh and it's free.
EDIT: well, sorry. Vinko posted before me and now i've learned a new thing :)
Apparently the free NetDrive software from Novell can access SFTP file servers.
Second David's answer below: I needed to mount a network drive automatically when users logged in. Dokan SSHFS is a nice tool, but wasn't reliable enough in this case. The copy of Netdrive I found didn't support SSHFS or sftp - not sure if a more recent one does.
The solution I'm trialling now involves adding a virtual network adapter (with file sharing disabled), using plink to open a tunnel via the new adapter to the remote machine running SAMBA, and mounting the network drive against the new adapter. There's another useful tutorial here http://www.blisstonia.com/eolson/notes/smboverssh.php.
The tunnel and network drive can be set up with a login script, so a few seconds after login users can use the mapped drive without needing to take any action.

Is there a WinSCP equivalent for Linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I love WinSCP for Windows. What is the best equivalent software for Linux?
I tried to use sshfs to mount the remote file system on my local machine, but it is not as user friendly as simply launching a GUI, plus it seems to require root access on the client machine, which is not very convenient.
Of course command-line tools such as scp are possible, but I am looking for a simple GUI.
If you're using GNOME, you can go to: Places → Connect to Server in Nautilus and choose SSH. If you have an SSH agent running and configured, no password will be asked!
(This is the same as sftp://root#servername/directory in Nautilus)
In Konqueror, you can simply type: fish://servername.
Per Mike R: In Ubuntu 14.04 (with Unity) it’s under Files → Connect to Server in the menu or Network → Connect to Server in the sidebar.
FileZilla is available for Linux. If you are using Ubuntu:
sudo apt-get install filezilla
Otherwise, you can download it from the FileZilla website.
I use FileZilla and it works fine with SFTP (SSH File Transfer Protocol). Follow these steps to install it and configure it:
1. Install FileZilla via terminal:
sudo apt-get install filezilla
2. Open the program and go to menu File → Site Manager... or simply type Ctrl + S
3. The following window should appear:
4. Enter the name of your host, select the port (usually 22 for ssh/scp/sftp) and choose SFTP - SSH File Transfer Protocol as the protocol and optionally set the Logon Type to Normal if authentication is needed, then enter your data.
A Xfce/Thunar solution is basically the same as GNOME/Nautilus:
Simply type sftp://yourhost/ in the address line in Thunar (you can get there by Ctrl + L).
(The authorization is identical to ssh/scp, i.e. with proper use of file ~/.ssh/config, keys and ssh-agent, you can achieve decent ease and security: server alias + no passwords asked.)
To run WinSCP under Linux (Ubuntu 12.04 (Precise Pangolin)), follow these steps:
Run sudo apt-get install wine (run this one time only, to get 'wine' in your system, if you don’t have it)
Download the latest WinSCP portable package https://winscp.net/eng/download.php
Make a folder and put the content of the ZIP file in this folder
Open a terminal
Type wine WinSCP.exe
Done! WinSCP will run like in a Windows environment!
gFTP
Konqueror's fish kio-slave (just write as file path: ssh://user#server/path
WinSCP works fine on Linux under Wine. I installed Wine and WinSCP and had no problems.
I've used gFTP for that.
Use FireFTP, Krusader, and other similar applications.
One thing I find WinSCP does well that I cannot do easily with Ubuntu tools is tunneling to a secondary machine. This is done with one with one connection setting in WinSCP. While I can use the native file browsers in Ubuntu (11.11) to reach any machine, I cannot easily tunnel thru an intermediate machine to reach a third one. I suspect it is because I do not well understand how to set up tunneling. I am toying with gSTM, but there is little documentation, and I suspect it is for setting up local tunnels, not remote ones. In any case it is not as dead simple as WinSCP made it. This is no anwser, but perhaps it highlights a critical feature of WinSCP that suggestions for alternatives should address.
Now off to learn more about tunneling...
Nautilus can be used easily in this case.
For Fedora 16, go to menu File → Connect To Server,
select the appropriate protocol, enter required details and simply connect. Just make sure that the SSH server is running on the other side. It works great.
This is valid on Ubuntu 14.04 (Trusty Tahr) as well.
One big thing not mentioned is the fact that with WinSCP you can also use key file authentication which I am unable to do successfully with Ubuntu FTP clients. KFTPGrabber is the closest thing I can find that supports key file authentication... but it still doesn't work for me, where WinSCP does.
Use Nautilus, the default file manager in GNOME. Here is how you may - Best SCP GUI on Linux.
If you're using Xfce (or LXDE) instead of GNOME, there's an equivalent tool: Gigolo.
I suppose, but not sure, it can be installed also on other desktop environments.
It supports FTP, SSH and WebDAV and it is quite intuitive to use: just click on Connect, choose the protocol, fill the parameters and go. You can save the connections for later use.
Just use GNOME. Just type in the address and away you go!

Resources