Archived Forum Post

Index of archived forum posts

Question:

SSH control characters

Jan 31 '13 at 21:28

How do I send control characters like CTRL-Z ? I tried sending \u001a in channelSendString and channelSendData, but that does not seem to work..


Answer

I didn't know the answer, so I Googled around a bit...

See these links:

http://www.techrepublic.com/blog/security/how-to-escape-ssh-sessions-without-ending-them/4507

http://lonesysadmin.net/2011/11/08/ssh-escape-sequences-aka-kill-dead-ssh-sessions/

http://binfalse.de/2010/09/ssh-escape-sequences/


Answer

Thanks.. I figured it out.. I used ChannelSendData and sent the hex character for CTRL-Z

char bytes[1] = {'\x1a'};

NSData *data = [NSData dataWithBytes:bytes length:1];

[ssh ChannelSendData:[NSNumber numberWithInt: channelNum] data:data];