Saturday, June 13, 2015

How to send message through SSH


There is another cool thing you can do while you are on ssh, you can broadcast/send message to other users that login to the same ssh server. In this article i will show you how to send message via ssh.

To send message on ssh, you can use "write" command, but first you need to know who is logged on the ssh server, you can do this by typing "w" command on the console.

w

kernelpanic@lubuntulaptop:~$ w
 12:40:08 up 44 min,  3 users,  load average: 0.23, 0.27, 0.22
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
kernelpa :0       :0               12:00   ?xdm?   1:34   0.09s init --user
kernelpa pts/2    :0               12:19    0.00s  0.04s  0.00s w
kernelpa pts/6    192.168.43.1     12:39    9.00s  0.09s  0.09s -bash

To send a message using "write" command, you must specify the username and the TTY and then the message you want to send, like this:

write [username] [TTY]

write kernelpanic pts/6

After you hit enter, you can type the message and it will send after you hit enter again, if you want to stop sending message, simply press CTRL + C on your keyboard.

Message that appear should look like this:

Message from kernelpanic@lubuntulaptop on pts/4 at 11:27 ...
hello, how are you today??
nice to meet you
EOF

There is another command that can be use to send message through ssh connection, which is the "wall" command, wall means "write to all", so basically wall command is still depends on write command.

The difference between wall and write is that wall will broadcast message to all active users (users that log in on the same ssh server).

Wall command can be use in two ways, first is like this:

wall <<< 'how are you guys'

Broadcast Message from kernelpanic@lubu                                        
        (/dev/pts/7) at 13:28 ...                                              
                                                                               
how are you guys 
Remember to put ' ' if your message is very long, and the second way is like this:

wall
good 
morning
everybody :)
^D
Noticed that the second command you must press CTRL + D (not C) and the message will be broadcast to all users.

That's it guys, now you know how to send message via ssh connection, be sure to check out this blog, because i have more interesting article coming up next.

~ have a nice day ~

 

No comments:

Post a Comment