Hiro
Posts: 78
Joined: Fri Dec 30, 2011 11:09 am

ssh

Sun Jun 17, 2012 4:09 pm

When i finally get a Pi i would like to run it headless as a torrent and email server (and possibly a few other things as well). I am intending it to be cli only to keep resource usage down so i have found cli torrent program (rtorrent) and installed it on my linux box and then shh'd into that box from a second linux box but cannot seem to access the already running program, all i can do is start another instance of it within my ssh session. I can see that rtorrent is running on the server with "top" in the session but don't know how to access it. I have googled but cannot find the answer, is it even possible?
Cheers, Hiro.

User avatar
jecxjo
Posts: 158
Joined: Sat May 19, 2012 5:22 pm
Location: Minneapolis, MN (USA)

Re: ssh

Sun Jun 17, 2012 4:18 pm

I'm running the same time of setup. What you want to do is look into a program called screen. This allows you to have multiple virtual terminal windows up in a single connection. Once you've started rtorrent you can detatch from the screen session and everything will continue running even after you disconnect. When you start up an ssh connection again you can reconnect and get right back into rtorrent or whatever other applications you are running.

I created a little video tutorial on how to use screen here: http://playterm.org/r/brief-screen-tutorial-1307563176
xmpp: [email protected]
Blog: http://jecxjo.motd.org/code

Hiro
Posts: 78
Joined: Fri Dec 30, 2011 11:09 am

Re: ssh

Sun Jun 17, 2012 5:13 pm

Cheers that's just the badger i needed. Not quite got it working perfectly yet, i named the session but when i do screen -ls i only get the number of the session not the name is this right? I assumed you would get the name as how else do you know which session is doing what. I guess i just got the naming bit wrong so i'll have another go.
Also once i detached i then used Putty to ssh in from my windows running laptop and after detaching there and going back to my linux box i found the session number i had used before was still listed as attached and my rtorrent was under another number. Not quite sure if that'll make sense to anyone reading it back but if i can get the session naming to work it will be irrelevant anyway.
Now just need to find a cli email client and i'll be sorted, thanks again, Hiro.

User avatar
jecxjo
Posts: 158
Joined: Sat May 19, 2012 5:22 pm
Location: Minneapolis, MN (USA)

Re: ssh

Sun Jun 17, 2012 5:22 pm

Sounds good. I only name sessions when I have multiple ones in existence...which is almost never. Can't think of the command line argument at the moment but I'd check the man pages (man screen) for further information.

Might I suggest installing mutt as your cli email client. It does a great job with POP and IMAP, very configurable, integrates with PGP nicely.
xmpp: [email protected]
Blog: http://jecxjo.motd.org/code

Hiro
Posts: 78
Joined: Fri Dec 30, 2011 11:09 am

Re: ssh

Sun Jun 17, 2012 6:46 pm

I am looking for a session for email, one for torrents and maybe another for file transfer, maybe just simple ftp or maybe something a little more modern and it would be nice to call the session by the name so i'll open another couple of sessions and try that.
Thanks for the advice on Mutt, i now have that installed and just need to get the config file sorted which looks a bit of a learning curve but there seems to be plenty of help on the net so should be ok.
Cheers, Hiro.

User avatar
jecxjo
Posts: 158
Joined: Sat May 19, 2012 5:22 pm
Location: Minneapolis, MN (USA)

Re: ssh

Sun Jun 17, 2012 10:28 pm

Ah I think I misunderstood your previous post.

So you can setup screen with a default list of windows with titles and applications. For example here is one that opens mutt, lynx, atop and a shell.

$HOME/.screenrc

Code: Select all

startup_message off

screen -t email 0 mutt
screen -t web 1 lynx
screen -t procs 2 atop
screen -t shell 3 bash
xmpp: [email protected]
Blog: http://jecxjo.motd.org/code

Hiro
Posts: 78
Joined: Fri Dec 30, 2011 11:09 am

Re: ssh

Mon Jun 18, 2012 6:51 pm

That doesn't seem to work for me, it is seeing the number in the line as the file name and tries to open it, hence the error "Cannot execute 0 No such file or directory" but if i leave the number off the line it opens the session and program but doesn't name it.
I managed to find a solution, "screen -S email mutt", it works for me but i am still interested in what the number is for or how i was misusing it.

User avatar
jecxjo
Posts: 158
Joined: Sat May 19, 2012 5:22 pm
Location: Minneapolis, MN (USA)

Re: ssh

Mon Jun 18, 2012 8:30 pm

Hiro wrote:That doesn't seem to work for me, it is seeing the number in the line as the file name and tries to open it, hence the error "Cannot execute 0 No such file or directory" but if i leave the number off the line it opens the session and program but doesn't name it.
I managed to find a solution, "screen -S email mutt", it works for me but i am still interested in what the number is for or how i was misusing it.
Oops, this DDoS is killing the CSS on the forum and I think I accidentally just reported your post rather than reply...sorry :cry:

So what I originally meant to say was the code block I supplied was for your /home/<username>/.screenrc file. Not sure if I made that clear. If you create that file and run screen then you will create all those windows on the fly. If you want to only load that in special cases, save the file as some other name and call the file directly screen -c ./specialrc
xmpp: [email protected]
Blog: http://jecxjo.motd.org/code

Hiro
Posts: 78
Joined: Fri Dec 30, 2011 11:09 am

Re: ssh

Mon Jun 18, 2012 8:55 pm

Now i see, that would probably have been obvious to most but i'm a little behind the curve at the moment. Will have to try that asap, Cheers.

User avatar
jecxjo
Posts: 158
Joined: Sat May 19, 2012 5:22 pm
Location: Minneapolis, MN (USA)

Re: ssh

Mon Jun 18, 2012 9:45 pm

Hiro wrote:Now i see, that would probably have been obvious to most but i'm a little behind the curve at the moment. Will have to try that asap, Cheers.
Its all good, that is what this forum is for. Good Luck!
xmpp: [email protected]
Blog: http://jecxjo.motd.org/code

Hiro
Posts: 78
Joined: Fri Dec 30, 2011 11:09 am

Re: ssh

Tue Jun 19, 2012 7:59 pm

Yep, worked a treat, unfortunately i'm off on my hols Friday so no more playing for a couple of weeks:(. I suppose i could tell the missus this is a bad time seeing as i'm just starting to get the hang of it but i don't think she'll go for that.
Thanks again for your help, Hiro.

Return to “Beginners”