LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Closed Thread
  Search this Thread
Old 02-19-2020, 08:43 AM   #1
daweefolk
Member
 
Registered: Sep 2009
Distribution: raspbian
Posts: 94

Rep: Reputation: 15
Where to put ssh login script?


I often ssh into my machine, and then run 'screen -r' to connect to my (usually) running screen instance and pick up where i left off.
However, i feel it's tedious and could be automated.
My question is, where (like, .bashrc or wherever else) could I put a script to first check for a running screen instance; then if one exists, connect to it.
I'm ok with building the script, I just don't know where to put it.
 
Old 02-19-2020, 09:22 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,766

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
My guess would be to call it from .bashrc, if you want it to run every time you login...as when you su - to that user from a running session.

An alternative I use is to write the script with a name I can invoke with a couple of keystrokes by invoking the history.
For example: I have a script that scans my spamtraps named ckspam.sh. After login, I type !ck to invoke the script. Most of the time, it's also the last command I've used on a session, so up-arrow, enter will also re-execute. The latter probably wouldn't apply in your case, but if you had a unique-enough script name (sz.sh) you could invoke it with !sz anytime you wanted.
 
Old 02-19-2020, 10:09 AM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,766

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Poo! This is a duplicate thread. Posted my response to the other thread. Reported.
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Fast login via ssh / Slow login via login manager with machine in AD-domain c01d Linux - Server 2 03-01-2016 01:52 AM
script to sftp-auto-login and put a file niteen Programming 3 11-21-2013 07:29 AM
Put each daily cron task in a separate script or put them all in one script? veeruk101 Linux - Newbie 4 10-19-2011 07:10 AM
ssh-agent, ssh-add and ssh-keygen AND CVS raylpc Linux - General 2 11-19-2008 02:50 AM
Passwordless SSH with SSH commercial server and open ssh cereal83 Linux - General 7 04-18-2006 12:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration