Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to create a remote shell on OS X with NC.

I tried nc -l 1337 -e /bin/bash but it seems that the Mac version of NC does not support the -e option.

Does anyone know how I can achieve a remote shell on OS X preferably only using the built in tools?

Unfortunately SSH isn't an option. What I am doing has to be done solely from the command line (so GUI option alterations are out of the question). Also I am trying to avoid password's because it will cause problems for my client program.

EDIT: Apologies for lack of information. I thought I had added enough.

Basically, I have several VM's running OS X and need them to have able to use each others command line. My plan was to have NC running on each and the the main VM could send commands to them through a PHP script.

Also, the reason for wanting to use the build in commands/tools is because I this will eventually be run on physical hardware and Mac's will be added and removed regularly and I do not want to install new software on client machines.

The reason for avoiding GUI actions is that this will be run without supervision of myself and am trying to make this as seamless as possible. When a machine is connected, I am able to launch one command, and I need to do many commands and file transfers which is why a remote shell is what I am after.

share|improve this question
    
I just looked at rsh and it doesn't seem to do what I am trying to do, which is create a listening server which I can connected to and receive full command line access. –  Jamza Apr 28 '10 at 20:44
7  
Is there anything particularly wrong with using the built-in SSH server? –  Ignacio Vazquez-Abrams Apr 28 '10 at 20:53
    
@arjan: i expect he means netcat –  quack quixote Apr 28 '10 at 21:10
    
Still wondering about "one command". So, one line with multiple commands (separated with ;, or chained using || or &&) is not possible either? –  Arjan Apr 28 '10 at 22:17
    
(@Jamza, did you see my comment about chaining commands?) –  Arjan Apr 30 '10 at 5:24

5 Answers 5

up vote 2 down vote accepted

The usual way is to enable the ssh service for command line access.

The very Mac way to do this:

  1. Go to Sytem Preferences App
  2. Choose Sharing
  3. Check "Remote Login" checkbox

You should now be able to connect using any standard ssh client. Macs and linux/unix machines have it built in. PuTTY is a good choice on Windows.

share|improve this answer
    
Unfortunately SSH isn't an option. What I am doing has to be done solely from the command line (so GUI option alterations are out of the question). Also I am trying to avoid password's because it will cause problems for my client program. –  Jamza Apr 28 '10 at 20:59
1  
You use System Preferences to enable SSH. You do that once. After that, you use the ssh command from Terminal. ssh does not require passwords; the preferred security measure is public/private keys. If you do not have access to the GUI and need to enable command-line access, I refuse to help. –  Nate Apr 28 '10 at 21:01
2  
@Jamza: You really should consider putting important details such as these in the original question so that people don't have to keep guessing what you want. –  Ignacio Vazquez-Abrams Apr 28 '10 at 21:02
    
As Nate points out, the GUI involvement is a one time action. –  Doug Harris Apr 28 '10 at 21:17
    
You can enable SSH on a Mac from the command line: sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist –  Gordon Davisson Apr 29 '10 at 6:29

First off, nc (which I had no prior knowledge of) appears to be a kind of telnet program. Insecure at best and rather rudimentary. I would not advise trying to use it.

Second, you have failed to adequately describe what you're trying to do. Are you trying to remotely login to a Mac OS X computer from another computer? Are you trying to remote from the OS X computer to another? Are you trying to create some sort of remote server that's accessible externally?

Why can't you use SSH? Why can you adjust things via the system preferences?

share|improve this answer
    
netcat is probably more akin to ping than telnet ... it's a low-level TCP/UDP swiss army knife, so security isn't really netcat's concern. –  quack quixote Apr 28 '10 at 21:21
    
The problem with SSH is that it will require the users password, and pretty much everything will be going on in the background. –  Jamza Apr 28 '10 at 21:26
2  
@Jamza You can setup ssh keys so that no password is necessary. –  KeithB Apr 29 '10 at 2:01

Well The Problem you are having with NC ( assuming you are talking about NETCAT) the Apple Version does not have the -e option in its bin.

The best solution is, to Compile a GNU version of NC using the apple SDK, then replace the apple version with your own GNU NC version. as far as i know apple has no plans to add the -e option to appleNC.

I had to do this for a few apple daemons that were ...lacking.

hope this helps

share|improve this answer
1  
Don't Fear the ./Make –  Xiuhtecuhtli Apr 28 '10 at 21:30

Unfortunately SSH isn't an option. What I am doing has to be done solely from the command line

You can enable SSH access using sshd, or /usr/sbin/sshd -p 1337 to listen to a non-privileged port (hence not requiring a sudo password).

share|improve this answer
    
The problem with that was it requires root and the users password. The reason netcat seemed the best option was because it was there by default, did not require root and was a single command. The controlling server does not know any of the machines passwords. –  Jamza Apr 28 '10 at 21:43
    
@Jamza, ah, right, that still needs sudo, unless maybe if you're willing to open a different port? –  Arjan Apr 28 '10 at 21:54
    
@Jamza, can you get a public certificate on those machines? –  Arjan Apr 28 '10 at 21:57
    
Unfortunately not, All I have to start off with is to launch one command and what I want to do is create a remote shell so I can launch more commands and copy files (e.g. adding public certificates). The reason SSH is a problem, I or the control server does not know the users password, so cannot authenticate. –  Jamza Apr 28 '10 at 22:05

If you set up an SSH keys (for instance with "ssh-keygen -t rsa") with no passphrase and then put the public key (as found in ~/.ssh/id_rsa.pub) in the ~/.ssh/authorized_hosts file in the remote user's host, then you won't need to exchange any passwords and everything can be done from the command line using ssh.

share|improve this answer
    
Too bad Jamza cannot put such keys on the remote machines... –  Arjan Apr 29 '10 at 4:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.