close ssh connection mac 1

close ssh connection mac

[user]@[server]:~$ exit
logout
Connection to [IpAdress] closed

Here is what the above code is Doing:
1. It’s creating a new SSHClient object.
2. It’s loading the host keys from the user’s local known_hosts file.
3. It’s connecting to the remote server.
4. It’s authenticating with the username and password.
5. It’s executing the command “ls -l”.
6. It’s reading the output of the command.
7. It’s printing the output of the command.
8. It’s exiting the remote connection.

Similar Posts