SSH Command Examples - Unix / Linux Tutorials. SSH client utility in unix or linux server is used to logging into a remote host and execute commands on the remote machine. The rlogin and rsh commands can also be used to login into the remote machine. However these are not secure. The ssh command provides a secure connection between two hosts over a insecure network. The syntax ssh command is. Let see the examples of ssh command. SSH Command Examples. 1. Logging to a remote server. You can login to a remote server from the local host as shown below. Alternatively you can use the below ssh command for connecting to remote host. Note . If you are logging for the first time, then it will prints a message that host key not found and you can give yes to continue. The host key of the remote server will be cached and added to the directory in your home directory. From second time onwards you just need to enter the password. 2. Logging out from remote server. Simply enter the exit command on the terminal to close the connection. This is shown below. 3. Running remote commands from local host. Sometimes it is necessary to run the unix commands on the remote server from the local host. An example is shown below. The ssh command connects to the remote host, runs the ls command, prints the output on the local host terminal and exits the connection from remote host. Let see whether the ls command actually displayed the correct result or not by connecting to the remote host. 4. Version of the SSH command. We can find the version of SSH installed on the unix system using the -V option to the ssh. This is shown below. 5. Debugging the SSH Client. When we are not able to connect to the remote host, it is good to debug and find the exact error messages that causing the issue. Use the -v option for debugging the ssh client. 6. Copying files between remote host and local host. We can use the scp command to copy the files securely between the local host and remote host using the ssh authentication. To copy the file from local host to remote hosts /var/tmp/ directory, run the below scp command. To copy the file from remote hosts /usr/local/bin/ directory to local hosts current directory, run the below scp command.
PREVIOUS NEXT