I have a remote kernel on a server that I would like to use to process some data. The connection works, i.e, I'm able to use the local front end and the remote kernel. However, I cannot figure out how should I access from the remote kernel the data that are on my local machine.
I thought I could simply use Import with the path to my computer and to the file that I want to import, but I didn't succeed. Something like:
Import["computerName@ip_address:/Users/myUserName/Desktop/data.txt","Table"]
Import::nffil: File not found during Import. >>
Answer
After some fiddling I found a solution to directly access my local files from the remote kernel via SSH. If localuser is the user name on the machine that runs the front end on which are also the data you want to import from the remote kernel and 111.111.111.11 is the IP address of the same machine, you just need to type:
Import["!ssh localuser@111.111.111.11 cat /Users/localuser/Desktop/data.txt", "Table"]
To make this work smoothly you first need to set up public key authentication over SSH. Let remoteuser be the user name on the machine that runs the remote kernel and let 222.222.222.22 be the IP address of the remote machine.
On your local machine launch the terminal:
- Generate a public key:
- ssh-keygen -t rsa
- Ok, when asks to save it in:
- .ssh/id_rsa
- Press return when asks for passphrase.
- Press return againg when asks for passphrase.
- Copy the public key on the remote machine:
- scp id_rsa.pub remoteuser@222.222.222.22:/home/remoteuser
- Connect to remote machine:
- ssh remoteuser@222.222.222.22
- Append the public key (previously copied from local machine to remote machine) to the list of authorized keys:
- cat id_rsa.pub >> .ssh/authorized_keys
- Generate a public key on the remote machine:
- ssh-keygen -t rsa
- Ok, when asks to save it in: -.ssh/id_rsa
- Press return when asks for passphrase.
- Press return againg when asks for passphrase.
- Copy the public key on the local machine:
- scp id_rsa.pub localuser@111.111.111.11:/Users/localuser
- Exit from remote server: CTRL+D
- Append the public key (previously copied from remote machine into local home) to the list of authorized keys:
- cat id_rsa.pub >> .ssh/authorized_keys
Comments
Post a Comment