I have a server in the web and I'm very concerned about security. I'm using custom private key

ssh-keygen -t rsa -b 4096 -C "email@example.com"

and I'm using it only for this server. I've added this key to authorized_keys on the server.

I'm using this ssh command to login:

ssh user@xxx.xxx.xxx.xxx -i key_file

But, after successful login, I'm able to login to my server using this command:

ssh user@xxx.xxx.xxx.xxx

without setting -i key_file. Why is that ?

2 Answers 2


Most likely you are adding -i PATH to your key_file which is being stored in default location. So basically it doesn't matter if you provide -i argument or not, since ssh will search for the key file in a default location anyways.

-i identity_file

Selects a file from which the identity (private key) for public key authentication is read. The default is ~/.ssh/identity for protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/id_rsa for protocol version 2. Identity files may also be specified on a per-host basis in the configuration file. It is possible to have multiple -i options (and multiple identities specified in configuration files). ssh will also try to load certificate information from the filename obtained by appending -cert.pub to identity filenames.


  • please cite your sources when you copy/paste
    – schroeder
    Oct 10, 2017 at 13:52

Possibly you are using ssh multiplexing. This is activated by the ssh option ControlMaster auto given in /etc/ssh/ssh_config or ~.ssh/config or at the commandline.

This feature allows the sharing of one underlying socket for multiple logical connections. Authentication only occurs once.

If you start ssh with the -v switch some information about mux for multiplexing can be seen.

blafasel@talbot:~$ ssh -v some.whe.re
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /home/blafasel/.ssh/config
debug1: /home/blafasel/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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