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.

My supervisor has given me remote access to his computer by logging in through ssh on my local computer. Although I am connected (and can view any files I wish through vi, emacs), how can I copy files to my local computer without having the password?

scp, for example, prompts for the password. From an internet search, it seems that creating public keys to bypass passwords for scp require at least one password entry during installation. Since I am not administrator on this computer, I am prevented from installing new programs, as suggested here.

share|improve this question
The password option for SSH keys is optional and is not required to make any keys (for the current account). –  nerdwaller Jul 8 '13 at 17:51
Correct, but how can one move the key over to the remote account without scp? –  Doubt Jul 8 '13 at 17:54
You only have a session running currently and are asking for advise on how to permanently get access to the system? –  Squeezy Jul 8 '13 at 18:07
@AaronMiller addresses that question, cat it to your console and copy it over. There is nothing special about the local file (you may need to adjust local permissions on the new file, of course). As others voice - we are operating under the assumption that this was deemed "ok" by your super. If it is not, get the okay first - otherwise stop... –  nerdwaller Jul 8 '13 at 18:34

2 Answers 2

If you have an active shell on the remote computer, and assuming the terminal emulator supports copy-paste (which all the popular ones do), you should be able to copy-paste across the public key once generated; something like tee >> ~/.ssh/authorized_keys, followed by pasting the contents of the public key file, would serve. You'd want to make certain that there are no extraneous line breaks in the result.

In providing this answer, I do of course assume that you have consulted your supervisor and obtained authorization to make this change. Otherwise, to do so would at best place your job at extremely justified risk; an untrustworthy employee is worse than none at all, and frankly, if you did this with my account and I hadn't OK'd it in advance, I'd fire you on the spot.

share|improve this answer

SSH allows you to run commands on the remote system. Without any commands specified, it creates a pty and launches the shell, which is likely the only way you're used to invoking it.

If you want to run cat to display a file instead of launching a shell, just run:

ssh remote_host cat /remote/file/to/view

That will display the remote file and return you to your local shell prompt.

If you want to save that file, just redirect the output to the local file you want to save it as:

ssh remote_host cat /remote/file/to/view > local/file/to/create

If you want to copy an entire directory, you can pipe the output of tar over the ssh session:

ssh remote_host tar cf - /dir/to/copy | tar xvf -

The local tar process (the one extracting the archive) will strip the leading / off if you've specified an absolute path in the remote process like the above example. The example would create a dir/to/copy folder heirarchy in your local host's current directory. If you'd like to strip additional path components, use the --strip-components option.

As an aside, if you want to connect to the host and edit the file in vi in a single step, you'll have to tell ssh to create a pty for you using the -t option:

ssh -t remote_host vi file/to/edit

If it's invoked interactively (no command specified so it launches a shell), it's smart enough to create the pty by default. With a command, specified, you have to explicitly tell it to create the pty.

See the ssh manpage for more details.

share|improve this answer
This all requires a password though, correct? –  Doubt Jul 9 '13 at 5:50
If you've created a keypair, pushed the public key to the remote's .ssh/authorized_keys file, and either specify the private key on the commandline or are running an agent such as ssh-agent, no. I don't know how the original poster's boss set things up such that ssh works but scp doesn't. I figured that was out of scope.. –  user234999 Jul 11 '13 at 6:35

Your Answer


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.