ssh Command - Connect to SSH Server

You can use the ssh command to connect to an SSH server and execute commands using the SSH protocol.

ssh ConnectInfo

Describe the connection destination as follows. If you omit the user name, it will be the same as the local user.


This is a sample to connect with ssh.

ssh kimoto@

Specify the port number

Use the "-p" option to specify the port number to connect to with the ssh command.

ssh -p 55555 kimoto@

Default private key used by ssh command

The default private key used by the ssh command is:


Specify the private key file

You can specify the private key file with the "-i" option for the private key. In the case of a relative path, it will be the path from "~/.ssh".

ssh -i id_rsa_example kimoto@
ssh -i /path/id_rsa_example kimoto@

Setting to use by specifying the private key file when SSH connection to a specific domain

You can use the configuration file "~/.ssh/config" to specify the private key file for SSH connection to a specific domain.

This is a sample setting to use the private key created when connecting to Github via SSH. Add to "~/.ssh/config".

Host github
  IdentityFile ~/.ssh/id_rsa_github
  User git

Let's also set the permission to 600.

chmod 600 ~/.ssh/config

Associated Information