Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Thursday, March 12, 2009

Mounting a remote SSH file system in Ubuntu... for Windows Admins

If you're somewhat new to Ubuntu or Linux you might be looking for a way to mount something like a file share the way we would a network drive in Windows. You know... mount a Z: drive, and then browse, and modify the contents of that drive as if it were local. Well, because Ubuntu is really friendly - you probably don't have to learn a whole lot to actually start getting useful things accomplished (in Ubuntu, Places>Connect to Server gives you most of what you need). But – did you know you can also securely mount a remote file system via SSH and have it look and feel local? Or perhaps you don't know what SSH is. If this is you – then check out this mini how-to. Nothing in here is particularly difficult... but there's enough here and linked-up to more expansive how-to's as to possibly be eye-opening for you.

What do you get out of following this tutorial?

You get a secure Linux alternative to a Windows network drive mapping that works works well... especially over slow connections (VPN tunnels, modems, etc.), and that you can essentially treat as a local resource. After that, you can do even more useful stuff like use grsync/rsync to replicate differences between directory structures. If this is all new to you, you'll also get some useful exposure to openssh, scp, Putty, and SSHFS.

How-To

  1. Install the openssh server and client on the server, and the client on the client. Just use “sudo apt-get install openssh-server openssh-client”.... Like this

  2. Install putty on your client (this isn't strictly necessary - but useful for troubleshooting)...

    1. 'sudo apt-get install putty'.

  3. On your server, consider changing the the default port in SSH from 22 to something else (like 512).

    1. 'sudo editor /etc/ssh/ssh_config"... change the 'port 22' to 'port 512'... then issue a restart of ssh... 'sudo /etc/init.d/ssh restart'.

  4. If you're using a firewall on the server, make sure you open that new port you just created in the previous step.

    1. If you're using"firestarter" in Ubuntu, open Firestarter ( System>Administration>Firestarter). Go to policy, and add an "inbound traffic policy" and let that new port (e.g. 512) in from your network (or perhaps something more restrictive that makes sense).

  5. Putty on your client (from a shell, just type 'putty'). Now determine the IP address of your host server, and point putty at it, on the correct port and connect. It will prompt you for credentials... now you have remote telnet-like access to the remote box. In other words, all we're doing here is proving to ourselves ythat the "server" from earlier steps is actually working correctly.

  6. For good measure, try doing a scp from your client to the server (learn how SCP works).

    1. 'scp -p 512 /home/username/somefilethatexists.txt username@remotehostIP:/home/path/NewFileOnThisSystem.txt'.

    2. In the above, I'm specifying 512 for my port, and the username@remotehostIP is me forcing the right username... if I didn't do this, it would automatically attempt to use the username of the currently logged-in account on the client .

  7. At this point you've more than proven that everything works right (steps 5, 6). So the last steps are mounting and using that remote filesystem. The credit for the remainder of this goes to this older post by Carthic... but my cliffnotes follow below.

  8. Install sshfs ('sudo apt-get install sshfs'... note that this auto installs fuse as well).

  9. Now create the mount point on the client ('sudo mkdir /mnt/remotecomputer', and make yourself the owner... 'sudo chown yourusername /mnt/remotecomputer')

  10. Now add your username to the fuse group that was auto-created in step 8.

    1. 'sudo adduser yourusername fuse'. Or in Ubuntu, System>Administration>Users and Groups

  11. Log-out and log back in (users can't run the fuse binary).

  12. Finally - just mount that SSH filesystem off of the mount point you created earlier...

    1. "sshfs -f -p 512 username@ipaddress:/home/path /mnt/remotecomputer".

    2. It will prompt you for a password... type it, and now you can browse the file system of the remote server by doing an "ls /mnt/remotecomptuer" from your client. The remote file system works just like it's local... you can open and edit those remote files modify them locally and when you save them, they save to the destination server.

Now that you've got everything working correctly, you can do fun stuff like setup grsync/rsync if you actually want to replicate files from the “server” to your client (perhaps for doing easy backups over the WAN)... or if you didn't have exposure to SSH until now, you've got an easy to do remote control. Hope you found this interesting and useful.

Monday, December 15, 2008

VMware server 1.0.7 on Ubuntu, "Cannot open the disk... Failed to lock the file" error.

My searches turned up a number of hits, but nothing specific for VMware server 1.07 build-108231 or Ubuntu 8.10. In any case, my Windows XP guest instance wouldn't start, reporting an error of "Cannot open the disk 'somefile.vmdk' or one of the snapshot disks it depends on. Reason: Failed to lock the file". The scenario that prompted this was that the host OS was shutdown hard while the guest was still in the process of shutting down.

If you check out the path of the problem guest instance... (e.g. /var/lib/vmware/Virtual Machines/ProblemGuest), you should see a few *.WRITELOCK files. Just rename those *.WRITELOCk files to something else... like *.OLDWRITELOCK. After doing so, go back to the VMware Server console and startup your guest - it should fire-up without incident.

Monday, February 25, 2008

Getting email links to Work with Deki Wiki and Exchange

As I've mentioned, we're running Deki Wiki 1.8.3c on Ubuntu 7.10 and we have an SBS/Exchange 2003 box serving as our SMTP server. In DekiWiki, whenever someone uses the “email link” functionality, we want the email that get’s generated to be delivered to their Exchange mailbox. So, after getting LDAP integration configured properly, we looked at the email piece. In addition to the FAQ, there are some resources in the Deki Wiki forums.

If you’ve got a similar site configuration, you can do everything to get this working through either DekiWiki's Control Panel web interface, or though the LocalSettings.php file. Or, you could install a local MTA on Ubuntu like Exim4 - but it's not really necessary. Since we have an SMTP server in production, we're using PHPMailer which is part of the DekiWiki pre-req install list... it passes messages though to the SMTP server. From Deki Wiki, go here:

  • Go to Tools>Control Panel>Configuration
  • admin/smtp-server: Exchange server IP address
  • mail/smtp-servers: Exchange server IP address (or mail.mydomain.com)
Note, you may need to add the "mail/smtp-servers" option in the control panel.

Friday, January 18, 2008

Ubuntu: Start the Virtual Machine Additions during startup

If you followed the last post, you might want to configure the vm-additions to run at startup. The Ubuntu-way of making this happen is documented here.

The short version is as follows: (note the trailing ... "S .")

$ sudo update-rc.d vmadd start 51 S .
$ sudo update-rc.d vmadd-heartbeat 51 S.
$ sudo update-rc.d vmadd-timesync 51 S.

Thursday, January 17, 2008

Getting Virtual Machine Additions (for Virtual Server) to work in Ubuntu 7.10

As anyone who’s worked with Linux distros under Virtual Server 2005 R2 SP1 can attest, getting them running is not particularly fun. Assuming you get past video problems, and can get your guest built, you then have to contend with limited support for vm-additions, CPU utilization problems, and the like. With apparent Linux-support improvements forthcoming, you might be able to wait. But if you can’t wait, it is possible to get the vm-additions installed and working in Ununtu. The key to making this work is converting the RPM’s to DEB packages via alien. Despite forum posts to the contrary, it will work.

After you’ve got your Ubuntu guest installed and running, grab a copy of the vm-additions and either mount the ISO in the guest via the management console, or just extract and copy the RPM’s over to the guest instance via SMB . After doing so, use alien to convert the RPM files to .DEB files, like so:

“$ sudo alien -k --script vmadd-full-2.0-1.i386.rpm”

Now that you’ve converted them, you should have *.DEB files in the directory you were working in. Go ahead and launch your package installer (e.g. GDebi Package Installer), and install vmadd-full-rhel_2.0-1_i386.deb. It should display a message to the effect of … “The Microsoft VM additions… (converted by alien)”. At this point, Gnome crashed on me (down at the bottom of VMAdditionsForLinux-README.txt in the vm-additions ISO it refers to having to exit the GUI). I’m telling you this because Gnome crashing doesn’t necessarily mean it’s broken.

If you’ve reached this point, for good measure check the install log.

It lives here… /var/log/vmadd-install.log

The only thing left to do would be test it…

“$ /etc/init.d/vmadd start”
“$ /etc/init.d/vmadd-heartbeat start
“$ /etc/init.d/vmadd-timesync start