How to Connect Remote Host Using the ssh Command

The ssh command allows you to connect to a remote system, or to execute a command on a remote system. The format of the ssh command to connect a remote system is:

# ssh [options] [user@]host [command]

The host argument is the name of the server that you want to connect to, and is the only required argument. For example, to connect to a remote host named host03, enter only the following:

# ssh host03

ssh remote host using a specific user

When you do not specify a user while connecting a remote host using ssh, it attempts to connect to the remote host with the same username that you are logged on as on the local system. You are prompted for only the remote user’s password. To connect to a remote host as a different user, provide the user@ argument:

# ssh root@host03

Execute a command on remote system

To execute a command on a remote system, include the command as an argument. ssh logs you in, executes the command, and then closes the connection, for example:

geeklab# ssh root@192.168.219.149 ls
root@192.168.219.149's password: 
anaconda-ks.cfg
initial-setup-ks.cfg
test
geeklab#
Related Post