ssh, truecrypt, sshfs in a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh, truecrypt, sshfs in a script
# 1  
Old 04-06-2011
ssh, truecrypt, sshfs in a script

Hello all,

First time posting, although the site has helped solve many problems in the past!

I would like to create a script to simplify a series of commands that I run:

Log into the ssh-server (RSA key)
Code:
ssh username@hostname -p 6110

Once there, I mount a truecrypt volume:
Code:
truecrypt /media/uhd/container ~/mnt

After entering the password to complete the mount, I log out from the ssh-server
Code:
exit

I then mount those files locally:
Code:
sshfs username@hostname:~/mnt /media/remote -p 6110

Once I have finished working, I unmount the remote volume:
Code:
fusermount -u /media/remote

I then log back onto the ssh-server to unmount the truecrypt container:
Code:
ssh username@hostname -p 6110

Code:
truecrypt -d

I've made some simple scripts for vnc through ssh, but I've not managed to make much headway on scripting this.

I'm presuming I'll need two scripts: one to mount the truecrypt container and then mount that locally, and another script to dismount the remote container then dismount from truecrypt.

Any pointers on how to go about this would be very much appreciated! (and indeed whether I can refine the process)

-- Added with regard to alternative method --

Although I can mount the drive locally then use truecrypt locally:
Code:
sshfs -p 6110 username@hostname:/media/uhd/ /media/remote -o allow_other

The (lack of) speed in accessing the truecrypt contents makes it unworkable. I've put this down to the very slow server

---------- Post updated 04-06-11 at 03:44 AM ---------- Previous update was 04-05-11 at 02:05 PM ----------

Well, I'm still not getting very far with this one.
If I try the following:
Code:
#!/bin/bash
ssh -v -p 6110 username@hostname 'truecrypt /media/uhd/container ~/mnt'

It just hangs indefinitely after sending command: truecrypt /media/uhd/container ~/mnt ... which is the point at which I would be expected to enter the truecrypt container's password.

Any clues on what I can do in order to get the password prompt?

Last edited by freshtoast; 04-05-2011 at 05:13 PM..
# 2  
Old 04-06-2011
I don't have truecrypt, but a well written program will open /dev/tty and communicate with it to obtain a password from a user. When you run a command remotely via ssh you won't have a controlling terminal so that is not possible. If you're willing to compromise security in the name of automation, your local script could obtain a password from the user and then pass it to truecrypt on the command line.
# 3  
Old 04-06-2011
Your alternate method of running truecrypt locally seems to be the very best approach. It doesn't make sense that it would be slow unless the server is able to run truecrypt very quickly and the local machine is very slow or resource-limited.

Since the data is already encrypted, maybe you could serve it with NFS instead of SSH.

Are both machines running Linux?

BTW, Fedora Linux renames truecrypt to realcrypt.
# 4  
Old 04-06-2011
Quote:
I don't have truecrypt, but a well written program will open /dev/tty and communicate with it to obtain a password from a user. When you run a command remotely via ssh you won't have a controlling terminal so that is not possible. If you're willing to compromise security in the name of automation, your local script could obtain a password from the user and then pass it to truecrypt on the command line.
Thank you for the reply. I think that is the bit I was missing (and hence going around in circles) - the lack of a controlling terminal. I will certainly look into the alternative you describe and see how much security is compromised.

Quote:
Your alternate method of running truecrypt locally seems to be the very best approach. It doesn't make sense that it would be slow unless the server is able to run truecrypt very quickly and the local machine is very slow or resource-limited.

Since the data is already encrypted, maybe you could serve it with NFS instead of SSH.

Are both machines running Linux?

BTW, Fedora Linux renames truecrypt to realcrypt.
Thank you for your reply too. I definitely think the server is the weak link (533mhz via epia!) and struggles with most tasks, whereas I have no issues handling the truecrypt volumes on my local machine. However, the container is very large (75gb) so I'm not sure how the decryption works when the encrypted volume is locally mounted Smilie It certainly isn't sending the whole container over before decrypting!

Both are running linux (ubuntu 10.10 and debian squeeze)

Perhaps a server upgrade is in order...
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

SSH tunnel working for ssh but not for sshfs

I'm trying to setup a link between my home pc (work-machine) and a server at work (tar-machine) that is behind a gateway (hop-machine) and not directly accessible. my actions: work-machine$ ssh -L 1234:tar-machine:22 hop-machine work-machine$ ssh -p 1234 user@127.0.0.1 - shh access on... (1 Reply)
Discussion started by: Vathau
1 Replies

2. Shell Programming and Scripting

Sshfs script

Hi, I am new to this forum. I want to setup my personal Dropbox between my home server and the work station in the office. I followed this tutorial danbishop.org/2011/09/10/...-in-os-x-lion/and it works great. :) The trouble now is I am not sure how I can make it to start on boot. ... (3 Replies)
Discussion started by: macpc
3 Replies

3. Solaris

Alternative to sshfs?

I have an automated testing script that relies on the dev box being able to see production's (NFS) share. It uses rsync and ssh to handle transfers and command execution; however, it also needs the production share mounted in order to run Perl code against it when Unix commands via ssh will not do.... (2 Replies)
Discussion started by: effigy
2 Replies

4. Shell Programming and Scripting

Mount twice sshfs dir

Hi everyone. I have 3 machines, let's call them store, node1 and node2. I have to mount on node1 and node2 the same directory of store. So, I launch the sshfs command on node1 and everything works fine. But when I try to do that on node2, it hangs for a while and then I obtain:... (0 Replies)
Discussion started by: canduc17
0 Replies

5. UNIX for Dummies Questions & Answers

sshfs twice on the same dir

Hi everyone. I have 3 machines, let's call them store, node1 and node2. I have to mount on node1 and node2 the same directory of store. So, I launch the sshfs command on node1 and everything works fine. But when I try to do that on node2, it hangs for a while and then I... (0 Replies)
Discussion started by: canduc17
0 Replies

6. Solaris

Solaris 8 and sshfs

Hi, all.. Does Solaris 8 support sshfs? (Sorry if my question is too simple :o) We are going to mount a file system from Solaris 8 on HP-UX 11i. Will things will go smoothly with this? Will there be any performance problem if the number of users grow to perform I/O operations on mounted fs? ... (4 Replies)
Discussion started by: swmk
4 Replies
Login or Register to Ask a Question