Blog is moving

My blog is moving to http://victormendonca.com/blog/. If you are looking for a specific or older post you are in the right place Otherwise check out my new page for more up to date content.

Tuesday, October 16, 2007

How to simply transfer files to another PC via SSH


Today I was trying to find a way of logging on my web server as root so I could transfer files to my ftp and web folders without having any permission problems.

I usually do it through ftp as an ftp user. I transfer the files to the server, than I logon to a terminal via ssh and manually move all the files to the desired place. After that I still have to chown and chmod. It's not a lot of work, but I like making things simpler!! :)

My server is on a DMZ, so I don't want to open access to any unnecessary port. I also limit a lot of the logins to my subnet so no one can access from the Internet.

I really don't like scp for large files, so that was a no no.

What I was trying to do was to enable root login to vsftpd and limit subnet login on hosts.deny hosts.allow. I went trough all the steps but them I could not get it to work.

After asking for some help on Ubntu forum, someone told me to try sshfs l, which depends on fuse. Both packages are easy to install. You can download a tar file and quickly compile it.

Once I had it installed all I had to do was run the following codes to mount a server folder to a empty local folder and unmount respectively:

# mount
$ sshfs user@server:[remote folder] [local folder]
# eg:
$ sshfs root@myserver:/ /home/juanito

# unmount
$ fusermount -u

It's pretty neat if you want to mount a remote folder trough SSH, but for me it was not yet what I needed. For some reason I did not have complete access. I could create folders, files and transfer the same anywhere but could not delete them. No deal!!

After some more searching I found something that made feel stupid (in most cases the simpler is the best). All I had to do was enter the following on Nautilus address bar (Ctrl+L if you can't see it):

ssh://user@server

Shazam!!! I had now complete access to my folders. You can use the same method for ftp, smb and sftp protocols as well.

If this is a server you use a lot you can even mount the login to your PC so you don't have to type the address all the time (yeah, I'm also lazy).

Go to main gnome menu => Places => Connect to Server


Choose SSH


Fill the fields:
Server - Your SSH server IP
Port - 22 (or other if you have changed)
Username - Local username on the remote machine
Name to use for connection - Human readable


Now every time you login you'll see and icon on you desktop and your Nautilus side pane like this:


The icon on your desktop can be removed using gconf, but that means that any mounted volume (eg: flash USB, CD) will not show on you desktop, but will on your "Computer" folder (and of course on your "/media" folder).

So to remove the icon, open gconf editor (Alt+F2, enter gconf-editor), go to /apps/nautilus/desktop and uncheck "volumes_visible". You can also enable "computer_icon_visible" to have something similar to "My Computer" on Windows.


Vic.

PS: the steps above for ssh access assume you have installed shh on the client and sshd on the remote PC

No comments: