Monday, November 10th, 2008 | Author: Angelo

SSH without authentication while opening multiple sessions.

While working on a remote server via SSH, we need to open multiple sessions for the same remote server. Suppose, you are logged into a server 10.10.10.1, and now you want to transfer a file to server X from your local machine. Then you will have to copy those files using scp, for which you need to enter password while establishing a fresh connection to server X. So, it takes some time as well as it is irritating to enter password again and again.

Here’s the remedy :

Open the file /etc/ssh/ssh_config on your local machine as root to edit. Or if you are not the root user, you can create a file ~/.ssh/config for user level SSH configurations.

Add the following lines at the end of the file you opened just now:

ControlMaster auto
ControlPath /tmp/ssh-%r@%h:%p

Save the file and you are done !!

Now check out (One can try it this way) - Open a terminal and connect to a server :

$ ssh root@10.10.10.1

The connection gets established after entering the proper password.

Then in another terminal try to copy a file from your local machine to the same server :

$ scp -r ~/pintos root@10.10.10.1

This time, you don’t need to wait for a fresh connection, neither you will have to enter the password again. File transfer starts instantaneously. SSH shared the already established connection. Similarly you can open another terminal without waiting and entering the password again.

Category: Linux
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

5 Responses

  1. Torgny
    You can use this trick for all type of users it is not necessary that user must be root. In case of user other than root you will have to upload config file in .ssh directory of particular user i have mentioned it in post.

    Also it is helpful when you accessing server from such machine where you don’t have private key.

  2. Very interesting, are there any security issues in doing so?

  3. 3
    Torgny Bjers 
    Monday, 10. November 2008

    There are a lot of security reasons for not using this method. I would recommend using public key authentication instead. I found this seemingly good how-to on Google, I am sure you could find more if you needed to:

    sial.org/howto/openssh/publickey-auth/

    There will be no need to enter a password except if you create one for the private key. As long as you do not distribute the private part of the key it will be as secure as it gets.

  4. Thanks Torgny, I’m extensively using public keys to login remote computers, but there are some cases in which this is not possible, mainly:

    -> When the server disable this kind of authentication
    -> And when the login is also doing a kerberos authentication for the AFS environment.

    In these cases having the shared connection can be useful. Can you better detail which are these security issues involved?

    thanks again

  5. 5
    Torgny Bjers 
    Tuesday, 11. November 2008

    hilbert00: In this specific case he’s logging in with a root account. If you have root access to the server to begin with, why would you not just enable public key authentication in the SSH server?

Leave a Reply