简体   繁体   中英

Using local system as ssh client and server

I am using local system to learn ssh and what I am trying to do is execute a command on the remote server. I have ssh server running on terminal1 and client on terminal2. I used the following command on terminal2:

ssh user1@127.0.0.1 echo Display this.

but it echoes on terminal2. How would I know if the command actually worked if it's not displaying in terminal1?
Thank you.

It worked correctly. It ssh'd into the server, executed the command, and returned the stdout of that command back to you.

SSH gains access to the server, but not necessarily any TTY's active on it. You would have to jump through some hoops to send text to a specific TTY, such as your Terminal1.

A better test would be:

ssh user1@127.0.0.1 'touch ~/testfile'

Then you can check on your server (which is localhost) to see if testfile was created in your user1 home folder. If it did, then the connection and the command succeeded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM