Remote directory creation

Is there a way to create a directory in some remote location from a local location?

I understand that we can use 'rcp' to copy a local file to a remote location.

I am looking for a command in similar lines which lets us create directories in remote locations.

Could someone help?

rcp should create subdirectories on the remote system, assuming privileges are correct.

Try remsh to execute the mkdir command remotely. (rexec is similar). remsh allows only one command, then breaks the connection. SO, to create the directory, then set privileges would require two lines -- two remsh commands.

Add your public key to ~user/.ssh/authorized_keys on host and then:

ssh user@host mkdir path

.

Hi Jim,
Thanks a lot for your suggestion :slight_smile:

I used 'rsh <remote server> mkdir -p <remote dir>' and it worked fine. Think, remsh should have done the same for me...

Hey I dont think 'rcp' could create subdirectories on a remote system. Tried it out and failed saying 'No such file or directory'

Thanks again...

Hi AbEnd,

Thank you for your reply :slight_smile:

But could not work it out... Could you tell me what a public key is?

I tried to execute 'ssh user@host mkdir path' but then, it prompts me for a password :frowning:

This is actually a "trick" that allows SSH to not prompt for password for logging in a remote session, by trying public key authentication first. If public key authentication fails, password authentication will be tried as a last resort.

Use ssh-keygen to generate a key pair. The private key is kept in your local account. The output key will be left in a file like id_rsa.pub and you just paste the line to ~/.ssh/authorized_keys on whatever remote host you would like to log on without prompting for password.

Note that you need to ensure the .ssh directory is readable by the account owner only or public key authentication may not work.

You will find more information on how to use ssh-keygen by a search online.