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.

UserName@HostName

This is a sample to connect with ssh.

ssh kimoto@59.105.185.193

Specify the port number

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

ssh -p 55555 kimoto@59.105.185.193

Default private key used by ssh command

The default private key used by the ssh command is:

~/.ssh/id_rsa

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@59.105.185.193
ssh -i /path/id_rsa_example kimoto@59.105.185.193

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 github.com
  HostName github.com
  IdentityFile ~/.ssh/id_rsa_github
  User git

Let's also set the permission to 600.

chmod 600 ~/.ssh/config

Associated Information