Remote ssh
I'm trying to run commands remotely from one Solaris box to another via root. We're using ssh on both of the boxes. I set up the /.rhosts and the hosts.equiv on the remote box. I also created /etc/ssh/ssh_known_hosts on the remote box and added the FQDN. I'm used to tru64 and linux, so I'm not sure what I'm missing for Solaris. :)
TIA!
answered my own question:
in order to get it to work, i had to run ssh-keygen -t rsa -f /.ssh/identity, then copy the resulting identity.pub file to the remote server's /.ssh directory, then cat identity.pub >> authorized_keys.
Similar Messages
-
How to reconnect to a disconnected remote ssh session on solaris 10
hi all
How to reconnect to a disconnected remote ssh session on solaris 10
is there a way to accomplish thisNo, there's not.
A common solution for this is to get a copy of 'screen'. After connecting via ssh (or any other protocol), you can start a "screen" session. If you get disconnected (or disconnect intentionally), you can later come back on the machine and bring your existing "screen" session back.
Darren -
Can not connect to a remote SSH server with my mac
Ok have tried 4 different applications, fetch , captain ftp, terminal, etc.
I am trying and connect to a friends ssh server to upload some file logs. I have the correct login/password, have tried both protocol 1 and 2. Port 22 is correct. I keep getting the error message
User logging error - captain ftp
SFTP connection to ..... could not be opened becasue the connection to the SFTP server could not be established or was lost - Fetch
sshexchangeidentification: Connection closed by remote host - Ternminal
We have tested it using Telnet and other programs on a PC and all is well.
When i try and connect he receives the message
Refused connect from cpe-"ip address"(ip address)
policy: HostKey/etc/ssh/sshhost_rsakey
Do i have a setting somewhere i am missing.1st, is the server behind a home router? Has port 22 been "Port Forwarded" from the internet side to the server's side of the router?
2nd, from a Terminal session use the command:
ssh -v -v -v [email protected]
The -v -v -v triplets will give you a wealth of ssh connection information. If you read through this carefully you may find the root cause of your problems (assuming the 1st step above doesn't yield results).
Another thing to consider, is that ssh will not make a connection to an account that it does not consider to be reasonably secure. This means that the home directory of the account and specific key subdirectories must have proper ownership and permissions, or ssh will not connect. The specific ownership and permissions needed and the files and directories checked are spelled out in the ssh man page
man ssh -
Remote ssh commands with wild cards
I am trying to send a remote command via ssh - need to get a file listing in a directory using a wild card. However, the ssh command will not return results using a wild card:
ssh [email protected] sudo ls -l /var/audit-files/201110* (directory requires root permission)
/var/audit-files/201110*: No such file or directory
I've tried quoting the command, the directory, the file names, etc - same results. It will only work with a specific name that exists, but not with a wild card. Is there a way to make this work?This is a rather complex situation. The problem is that you need to quote the '*' character; however, quoting it once may not be enough. Every time the command goes through a shell you'll strip out a set of quotes. It isn't clear to me how many times this will go through the shell but I'm guessing you'll have to at least double quote it.
ssh [email protected] sudo ls -l "/var/audit-files/201110\*"
I won't guarantee that this will work but it might. I don't know what the permissions are on /var/audit_files. If you need root to read that you may need to triple quote it. I've never had much luck getting the quotes right in complicated situations like this. -
I'm trying to setup an ssh server on my imac so I can connect to it when i'm at public wifi places with my mbp. I setup a new user account on the imac just for this purpose and have enabled remote login.
But when I try to login in from my laptop nothing seems to work right.
ssh [email protected]
the password prompt asks 3 times and then denies with errors
permission denied (publickey, keyboard-interactive)
or connection closed by 192.xxx.x.xxx
do i need to create a user account on my mbp with the same name or can i just login with a password?
please advise
Message was edited by: BdayzI'm trying to setup an ssh server on my imac so I can connect to it when i'm at public wifi places with my mbp. I setup a new user account on the imac just for this purpose and have enabled remote login.
But when I try to login in from my laptop nothing seems to work right.
ssh [email protected]
the password prompt asks 3 times and then denies with errors
permission denied (publickey, keyboard-interactive)
or connection closed by 192.xxx.x.xxx
I assume this attempt was while you were at home, as a 192.168.x.xxx address is not addressable across the internet.
do i need to create a user account on my mbp with the same name or can i just login with a password?
No.
System Preferences -> Sharing -> Remote Login, do you have Allow access for "All Users" checked, or did you change this to "Only these users"? If you did the "Only these users" option, try changing it, at least as an experiment.
As an experiment use the ssh -v -v -v command
ssh -v -v -v [email protected]
This will give you a lot of debugging information. Hopefully, it will give you some additional information about why your connection was refused.
You might also want to go through the "man ssh" man page, looking at "FILES" section checking for "permissions" descriptions under that section, as there are some key ssh files that if they exist (not all will), but if they do exist, must have specific permissions, or ssh will not allow you to login. For example, the destination user's home directory MUST NOT be writable by anyone except the owner. The destination user's home directory .ssh sub directory requires specific permissions, etc...
ssh works very well on Mac OS X. Once you manage to ssh while at home, you will need to configure your home router so that your port forward port 22 from the internet side of your home router to the Mac you are setting up as your home ssh server. PortForward.com has documents providing step-by-step guides on how to setup port forwarding for a huge list of routers
<http://portforward.com/>
By the way, Terminal, Unix, and command line command questions, such as ssh, are best asked in the Mac OS X Technologies > Unix Forum
<http://discussions.apple.com/forum.jspa?forumID=735> -
Calling a remote SSH script from a local script
When I paste this in Terminal I get the expected output:
ssh -2 root@$SERVER /Library/WebServer/Sectrum.com/Sectrum/RSS/Update.py
However when I invoke the same command scriptomatically I get error:
: No such file or directoryctrum.com/Sectrum/RSS/Update.py
It looks like the command line is truncated by a control character? What's going on?
Are there special rules when calling an SSH remote script from inside a script on the local machine?Just tried a test with
#!/bin/sh
ssh [email protected] command
with a remote (non-Mac OS X) box, and it worked as expected. Can you post more of an example, or can you try (for instance) invoking a bash script on the remote box with, say, an echo command or two? Try to break down the problem space here.
And in no particular order...
The root user wouldn't be my choice for this sort of thing, given the sensitivity of that username.
Try (for testing) using localhost as the host name, or the full host name.
Confirm $SERVER (and I'd probably use the ${SERVER} notation for that) is working with an echo.
And as a completely different approach, it might work to add and use a CGI path into the web server for this operation, too; to use a path other than ssh for the operation. Or (depending on what you're really doing here) maybe a periodic script. (Or Xgrid, maybe ARD or such, or any of various available distributed command environments.) -
Remote ssh connection dropping
Here is a strange issue, I have been facing of late. My router is setup to forward a particular port to my OUL box.
When I login from my home to this box which is at my office using a ssh connection with putty, it stays for a minute (even less at times), and drops off. I have made some changes to sshd_config etc., but don't really seem to have a solution.
What's worse, I have an Oracle db running on the box. There is also a small web application that we use for our internal needs. This is accessed by people on the road. Very often, they just get kicked out - not even a 404 - the server is not available. And it pings fine.
I have checked the /var/log/secure file - there were a couple of issues before that have been solved already (like having the serverlistening ip and port in sshd_config). Nothing shows up any more on it.
Any help will be greatly appreciated!For the dropping ssh connection, you could try to monitor the tcp packets using wireshark.
If the connection is dropped liked it supposed to be (reset packet from server; connection disconnected like it should), it's your server which is the culprit.
But the issue smells like an ip address conflict...If it IS an ip address conflict, the MAC address changes (if the server is in the same subnet, otherwise, the MAC isn't visible; routing is a TCP property, whilst MAC resolving is done on the IP level) -
[Solved] Remotely closing X apps over ssh
I'm trying to figure out a way to remotely close an application (like firefox) cleanly over ssh. I know I could run "kill [pid]" or "killall firefox-bin" to close it, but the default termination signal causes firefox to close immediately and give a message at its next start complaining about the program not being shut down properly. I tried several other signals, all of which had the same problem.
Is there a signal that I can issue from kill that will be equivalent to closing the application by clicking the X, pressing Alt-F4, going to File > Quit, etc? If not, is there some other command I can issue to accomplish the same goal?
Last edited by liquidsunshine (2009-03-30 21:56:43)@Bralkein:
i like the one liner, i've incorporated it into my script. i split it up only because i wanted more meaningful errors.
@liquidsunshine:
thanks for asking this question, this turned out a nifty script. i use pkill all the time, now i have wkill to gracefully close programs from CLI and it works from SSH just as well as locally.
here's the finished product:
#!/bin/bash
# wKill
# pbrisbin 2009
# gracefully close a program's window from
# a remote ssh session, or not
# requires wmctrl
# example usage: wkill firefox
# always exit cleanly
errorout() {
if [ $R -eq 1 ]; then
export DISPLAY=""
fi
echo "$1"
exit $2
# set DISPLAY to your remote X session if we're ssh'd
# though: maybe a "local DISPLAY=" would work?
# it'd be cleaner if it did
if [ -z "$DISPLAY" ]; then
export DISPLAY=":0.0"
R=1
else
R=0
fi
# get the PID by process name
PID=$(pgrep "$1") || errorout "no process by the name: $1" 1
# get the hex by pid
APP=$(wmctrl -pl | grep "$PID" | awk '{print $1}')
# some things don't get reported correctly
if [ -z "$APP" ]; then
APP=$(wmctrl -l | grep "$1" | awk '{print $1}')
if [ -z "$APP" ]; then
errorout "wmctrl can't find pid: $PID or app: $1" 1
fi
fi
# close the apps window
wmctrl -i -c $APP || errorout "wmctrl could not close app: $APP" 1
# put the DISPLAY back to prevent any problems
# do this only if we set it above
if [ $R -eq 1 ]; then
export DISPLAY=""
fi
exit 0
as Bralkein said, some windows might not get reported correctly. i added a nested if in there for two reasons:
a) anything running in a terminal (irssi, mutt, htop) will only be captured by this if they were started with the terminal. something like `xterm -e mutt`. if you opened xterm, then opened mutt. it will be listed as "bash ~" or something in wmctrl and the pid would be of mutt and not xterm... so we're kinda SOL there
b) b/c i'd rather get a nice "could not find pid: X for app: Y" instead of a grep or wmctrl error message (which is what you'd get if the $APP variable is empty)
other than the CLI app issue, it should pretty much catch every exception and run quite cleanly. now if only i knew a real programming language...
Last edited by brisbin33 (2009-03-31 00:26:49) -
Extend SSH remote session to prevent quick timeout
Hi
Hvaing problem on my Apps team keep on complaint their remote SSH session keep on timeout.
Just wondering anything i can do in order to extend their SSH remote session to their Oracle application server 10g.
thanks
NoelHi
what type of SSH software are they using ? it could be that the software is not sending keepalive packets.
If it is possible then you can set the software to send "keep alive" packets to keep the tunnel active even if the user does nothing for a while.
fx in putty this is done under connection and there you have
enable tcp keepalive
and
sending of null packets to keep session active
set this number to fx 50 ie 50 seconds between null packets to be sent within the keepalive.
Good luck
Hope This Helps -
SSH and REMOTE X......Not X Forwarding
I've setup several web servers at home for myself, a website, and WordPress on both virtual and real hardware to learn more about servers.
They have varied from just installing Apache on a Ubuntu desktop to installing my website and Wordpress on a lamp server without X.
I quickly learned the benefits of a server without X and a GUI, so I set a goal to setup and configure a lamp server without installing a GUI......and I finally accomplished it!!
Now I'll be the first to admit that I'm still more comfortable in a GUI environment compared to the command line. However, I have no problem using the command line when needed, and am comfortable navigating the file system and editing config files using nano, while still learning and trying to remember commands!!!
My question is where to get more info on how to access my current server without X installed, via SSH and remote X from my Arch desktop to use GUI apps.
I already use the "connect to remote SSH server" to remotely manipulate the file system over my local network using Nautilus.
If Nautilus will work via remote X, then all GUI apps in theory will work. I'm just having problems actually figuring out how to it!!!
I've read that, "By default, this feature is disabled (for security reasons)". So I need to
startx -listen_tcp
But to do that, I need to:
If this server is no longer running, remove /tmp/.X0-lock and start again.
But when the X server is not running, the tmp file referred to is not there!!
Any ideas on how to "toggle" this function on and off easily?
Security risks?
I would also appreciate any additional refrence material on remote X.
Last edited by jeff story (2009-10-11 19:42:15)mcover,
First, I'd like to ask you something. Did I really say something so wrong that you have to be a rude f#&ker in your reply and try to belittle me for not knowing as much about how Linux works as you?? Did I unknowingly insult you in some way? Sorry if I did.
mcover said:
What you want to do is, run a bunch of GUI apps remotely on your server (let's call it machine B) and forward their X output to your machine (machine A). That certainly defeats the purpose of a server, but heck.. it's all possible.
OK, based on that statement, either you aren't getting what I'm wanting to do, or perhaps you can explain why you feel that way.
No, I don't want to run GUI apps on my server and forward X.....Thats exactly what I don't want to do.
Quote mcover:
That certainly defeats the purpose of a server
When I'm NOT going to install anything additional on my server to do what I want, and ask for security considerations?
Wow....
Quote mcover:
But the remote-SSH feature of Nautilus is in no way remote X or X-Forwarding.
So lets see.....server has no X installed, no Nautilus installed, and I use Nautilus (remotely from the OS and file system I'm manipulating)
Nautilus front end (GUI) can't display without X .....
....hmmm, Sorry if i'm not being clear enough for you. Did I screw up on some Linux terminology or something???? Please elaborate...
Quote mcover:
But I do suggest you get comfortable with the command line
Oh, you obviously missed this paragraph I wrote in the original post then:
Now I'll be the first to admit that I'm still more comfortable in a GUI environment compared to the command line. However, I have no problem using the command line when needed, and am comfortable navigating the file system and editing config files using nano, while still learning and trying to remember commands!!!
Quote mcover:
Then you'd have to look into VNC or NX.
As I said, I don't want to add anything (packages) to my server, so VNC works without X installed?
So thanks for your reply, but no thanks, I'll wait until either someone who understands what I am asking replies, or I'll just do more research on this subject on my own.
BTW: This is the first time I have ever lashed out at someone on a public forum.....but then again, you kinda deserve it don't you.
Last edited by jeff story (2009-10-11 23:56:19) -
Cisco ASA 5505 - problem with ssh, icmp on OUTSIDE interface
Hi all,
I have a very strange problem with OUTSIDE interface and remote ssh. Well, I have followed documentation and configure remote access for ssh like this [1.]. If I want to connect from internet to OUTSIDE interface [2.] get no response and in log I can see this message [3.]. I really do not understand why is ssh connection dropped by OUTSIDE access-list [4.]? If I understand documentation correctly there is no impact for remote mangement/access like icmp, ssh, http(s) by interface access-list. So, why?
When I try ssh connection form internal network to INSIDE interface everything works fine and I can log in to ASA. If I try allow ssh in OUTSIDE access-list still no success and a get this message [5.]? It is strange, isn't?
The same problem with icmp if I want to "ping" OUTSIDE interface from internet a get thish message in log [6.] and configuration for ICMP like this [7.].
Full ASA config is in attachment.
Can anybody help how to fix it and explain what is exactly wrong.Thanks.
Regards,
Karel
[1.]
ssh stricthostkeycheck
ssh 10.0.0.0 255.255.255.0 INSIDE
ssh 0.0.0.0 0.0.0.0 OUTSIDE
ssh timeout 60
ssh version 2
ssh key-exchange group dh-group1-sha1
ASA-FW01# show ssh
Timeout: 60 minutes
Version allowed: 2
10.0.0.0 255.255.255.0 INSIDE
0.0.0.0 0.0.0.0 OUTSIDE
[2.]
ASA-FW01# show nameif
Interface Name Security
Vlan10 INSIDE 100
Vlan20 EXT-VLAN20 0
Vlan30 EXT-WIFI-VLAN30 10
Vlan100 OUTSIDE 0
ASA-FW01# show ip
System IP Addresses:
Interface Name IP address Subnet mask Method
Vlan10 INSIDE 10.0.0.1 255.255.255.0 CONFIG
Vlan20 EXT-VLAN20 10.0.1.1 255.255.255.0 CONFIG
Vlan30 EXT-WIFI-VLAN30 10.0.2.1 255.255.255.0 CONFIG
Vlan100 OUTSIDE 85.71.188.158 255.255.255.255 CONFIG
Current IP Addresses:
Interface Name IP address Subnet mask Method
Vlan10 INSIDE 10.0.0.1 255.255.255.0 CONFIG
Vlan20 EXT-VLAN20 10.0.1.1 255.255.255.0 CONFIG
Vlan30 EXT-WIFI-VLAN30 10.0.2.1 255.255.255.0 CONFIG
Vlan100 OUTSIDE 85.71.188.158 255.255.255.255 CONFIG
ASA-FW01# show interface OUTSIDE detail
Interface Vlan100 "OUTSIDE", is up, line protocol is up
Hardware is EtherSVI, BW 100 Mbps, DLY 100 usec
Description: >>VLAN pro pripojeni do internetu<<
MAC address f44e.05d0.6c17, MTU 1480
IP address 85.71.188.158, subnet mask 255.255.255.255
Traffic Statistics for "OUTSIDE":
90008 packets input, 10328084 bytes
60609 packets output, 13240078 bytes
1213 packets dropped
1 minute input rate 15 pkts/sec, 994 bytes/sec
[3.]
Jan 13 2015 06:45:30 ASA-FW01 : %ASA-6-106100: access-list OUTSIDE denied tcp OUTSIDE/193.86.236.70(46085) -> OUTSIDE/85.71.188.158(22) hit-cnt 1 first hit [0xb74026ad, 0x0]
[4.]
access-list OUTSIDE remark =======================================================================================
access-list OUTSIDE extended permit icmp any any echo-reply
access-list OUTSIDE extended deny ip any any log
access-group OUTSIDE in interface OUTSIDE
[5.]
Jan 12 2015 23:00:46 ASA-FW01 : %ASA-2-106016: Deny IP spoof from (193.86.236.70) to 85.71.188.158 on interface OUTSIDE
[6.]
Jan 13 2015 06:51:16 ASA-FW01 : %ASA-4-400014: IDS:2004 ICMP echo request from 193.86.236.70 to 85.71.188.158 on interface OUTSIDE
[7.]
icmp unreachable rate-limit 1 burst-size 1
icmp permit 10.0.0.0 255.0.0.0 INSIDE
icmp permit 10.0.0.0 255.0.0.0 EXT-WIFI-VLAN30
icmp permit any OUTSIDEYou're right that the ACL should not affect otherwise allowed communications to the interface address.
Try disabling the ip audit feature on your outside interface.
no ip audit interface OUTSIDE AP_OUTSIDE_INFO
no ip audit interface OUTSIDE AP_OUTSIDE_ATTACK -
How to change iCloud password on a remote Mac?
I use iCloud and Back To My Mac (BTMM) to access some of the computers I have overseas. Everything was fine up until yesterday when I had to change my iCloud password. I now have lost access via BTMM to those remote computers as they need to have the iCloud password updated in the iCloud panel in their System Preference (and the Back to My Mac option has to be disabled/re-enabled to have it restarted).
I have remote SSH access to those remote Macs (all running Lion and in one case Snow Leopard), so I have a working SSH shell on them. But I cannot figure out how to update the iCloud password that is stored on those Mac via command line. I can reboot them if needed of course remotely, I'd just need to update the password used for the iCloud services...
Having someone walk to those Macs, login with my account and have them enter the password for me is not really an option, as to do that I'd have to give them both my Mac's account password and my new iCloud password, which is not going to happen :-) In addition, some of the Macs are used by my parents and in-laws, with their computer skill being limited to knowing how to open Safari and the Mail app. They wouldn't be able to help in anything technical.
So... is there another solution other than buying a plane ticket to go overseas and do it myself?In case anyone wonders, I was finally able to update my iCloud password ont he remote computer. The key was SSH.
Issue this command to connect via SSH to the remote Mac:
ssh remote_computer -L 5800:127.0.0.1:5900
This forwards all traffic from port 5800 on your Mac to port 5900 (the VNC/Screen Sharing port...) on the remote Mac.
Then open the Screen Sharing app from your Mac. From there, connect to:
localhost:5800
This will actually connect you to the remote Mac, even though your iCloud password is wrong on the remote Mac. Now you have GUI access and you can login into your account remotely and update the iCloud password on the System Preferences on the remote Mac. -
ACE 4710. Unable to clear ssh sessions
Hi.
Once in the CLI of an ACE 4710, using the command "clear ssh session id" I am unable to clear/kill any of the remote ssh sessions established.
According to the administration guide, the "clear ssh .." command must clear the sessions, but it does not, or maybe I am missing something?
http://www.cisco.com/en/US/docs/app_ntwk_services/data_center_app_services/ace_appliances/vA1_7_/configuration/administration/guide/access.html#wp1050335
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Tabla normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}
ACE/CONTEXTO_A# show ssh session-info
Session ID Remote Host Active Time
13728 222.98.54.158:50556 67:43:38
13732 200.44.158.70:46172 67:43:36
13735 200.44.158.70:46174 67:43:36
13737 200.44.158.70:46177 67:43:36
ACE/CONTEXTO_A#
ACE/CONTEXTO_A# clear ssh 13728
ACE/CONTEXTO_A# clear ssh 13732
ACE/CONTEXTO_A# clear ssh 13735
ACE/CONTEXTO_A# clear ssh 13737
ACE/CONTEXTO_A# show ssh session-info
Session ID Remote Host Active Time
13728 222.98.54.158:50556 67:43:54
13732 200.44.158.70:46172 67:43:52
13735 200.44.158.70:46174 67:43:52
13737 200.44.158.70:46177 67:43:52Hello,
Seems to be working for me in my tests. Works in the Admin context and a user context, and when clearing connections from console connection or one of the SSH sessions.
ace-appliance-15/CTX1# sho ssh sess
Session ID Remote Host Active Time
24705 161.44.77.245:1586 0: 1:42
25100 161.44.77.245:1589 0: 0:27
25116 161.44.77.245:1590 0: 0:16
ace-appliance-15/CTX1# clear ssh 25116
ace-appliance-15/CTX1#
ace-appliance-15/CTX1# sho ssh sess
Session ID Remote Host Active Time
24705 161.44.77.245:1586 0: 2: 5
25100 161.44.77.245:1589 0: 0:50
What version of software are you running on your 4710? I am running the latest A3(2.4). Can you try this version?
Thanks,
Sean -
[Solved] Starting applications locally but not SSH
Ok, so.. argh..
I'm normally good enough to figure these _basic_ things out but i'm bashing my head right now.
https://wiki.archlinux.org/index.php/Autostarting
i want to run startx when logging in locally on a tty, but not when i initiate a user-session via SSH.
Normally i'd place profiling stuff in .bashrc (variables, user aliases etc) and place startx in say a tty1.conf or something under /etc/init.d but since Arch is running systemd and starting x is not a daemon per sae i'm all out of luck here.
How do you guys normally startx? and how do you separate autostarting applications locally, remote etc?
Ps. I've started stuff via .config/openbox/autostart so that's fine.
I need X not to iniatate every ssh session :)
Solution (one of many):
This solution will not only work through all terminals (meaning you don't check the terminal name) it will also not rely on tty or session names, it will instead check if the source is running under a X window (:0) or from an IP (10.0.0.1).
If non of the above it defaults to starting x.
Note: It will not distinguish running under systemd aparently and it also doesn't take in account if you're relaying X via SSH i guess (havn't tried that tho but it's an assumption).
sudo nano /etc/profile.d/gui.sh
#!/bin/bash
me=`who am i`
case "$me" in
*\(:0\)*) echo "Youre in X" ;;
*\(*.*.*.*) echo "Youre in SSH" ;;
*) startx ;;
esac
Last edited by Torxed (2013-06-12 07:24:46)jasonwryan wrote:
You could also use lastlog to determine if you are logged in on a TTY or pseudo-terminal:
┌─[Veles ~]
└─╼ lastlog -u jason | awk '/jason/ {print $2}'
pts/9
┌─[Shiv ~ ]
└─╼ lastlog -u jason | awk '/jason/ {print $2}'
tty1
# edit: or just grep it if you only need an exit status...
This feels unpredictable right off the bat mainly because there's other services being found in lastlog, also if two people login at the exact same time and one of them get a "spike" in the process priority you'll end up giving the wrong sessiondata to the wrong user unless you check the username logged in against lastlog but that requires more processing power then a case/if clause from a single output source. Speed is everything, logic is next and everything else falls behind
Tarqi wrote:
What about /usr/bin/tty?
.bashrc
tty | grep tty && startx
Edit: Check the DISPLAY Variable if you want to avoid starting multiply X-Servers. However, maybe $TERM might be another solution.
Locally:
[doxid@faparch ~]$ tty
/dev/pts/1
Remote SSH:
[doxid@faparch ~]$ ssh [email protected]
Last login: Wed Jun 12 02:27:53 2013 from 10.0.0.140
Youre in SSH
[root@lookabeaver ~]# tty | grep tty
[root@lookabeaver ~]# tty
/dev/pts/1
Don't think this is a viable option.
WonderWoofy wrote:
I think ewaller meant cut and not -cut. But even then, what he is suggesting is that you print characters 10 through 12. So it highly depends on the output length and therefore the number of letters in your username. If you has used something like this it would have worked:
who am i | cut -d' ' -f2
Might work, but you're probably feteching:
[doxid@faparch ~]$ who am i | cut -d' ' -f16
(:0)
Last edited by Torxed (2013-06-12 07:15:09) -
Disk image can mount from local terminal with "open" command but not via ssh
I have a disk image "backup_image.sparsebundle". If I go to the terminal on my machine and type "open backup_image.sparsebundle" the disk image mounts as expected. No problems. If I secure shell (ssh) log in from a remote Mac and execute the same "open backup_image.sparsebundle" a warning dialog pops up and states that "The following disk images couldn't be opened" followed by my disk name. This is incredibly odd because it used to work just fine. I didn't think there were any ACL differences between a local terminal shell and remote ssh. I mean a shell is a shell right? Or, it used to be and now it isn't? I'm not doing anything obviously incorrect (to me); I'm the same user locally and remotely, same path to disk image. This used to work fine before Mountain Lion.
Background: All of this started because I wrote a script that would ssh in to a remote machine, open the disk image on that remote machine, mount it across the network over afp and rsync. If I leave the disk image mounted on the remote machine, the script runs fine but if the image is close and I try to remotely open the image as I always did, it fails. The only thing that has changed in the system is, now, both machines are running Mountain Lion. Odd.
Suggestions?Storing the password for the remote disk image in the local keychain of the computer running the script (in to a variable), then passing it accross to the remote machine worked. I'm not sure why all of this changed moving from Lion to Mountain Lion but I suppose it is slightly more secure.
To programatically mount and sync a remote encrypted disk:
#!/bin/bash
if [ -n "`mount | grep ~/sync`" ]; then
echo "Already mounted"
else
pw=$(security -v find-generic-password -w -D "application password")
ssh -o ConnectTimeout=1 [email protected] "echo $pw | hdiutil attach /Users/user/backup_image.sparsebundle"
mkdir ~/sync
mount_afp -s "afp://matdup01:[email protected]/Disk Image" ~/sync
fi
if [ $? -eq 0 ]; then
echo "Mount succeeded!"
else
echo "Mount Failed"
exit 0
fi
rsync -vrxtu --delete-before --exclude _* "/Volumes/Media/new Media/" ~/sync/new\ media/
umount ~/sync
rmdir ~/sync
exit
Maybe you are looking for
-
Hi Folks, is there any report to display the POlis t for which the GR has been done and invoice notposted. Thanks for your reply and points will be rwarded Best Regards Srinivas
-
Create a folder in desktop with flex application?
Hi, i want to create and save a folder in my computer using my flex application, so is there an actionScript function to do this? Thank you, Celine
-
Date format under filter criteria is not right in ALV Grid
When a date is chosen from the available dropdown values, the value transferred gets extraneous characters and filter does not work. I've Provided the Screenshots Below: WHAT TO DO ? PLEASE SUGGEST.
-
Weird behavior after copying from one mac to another?
Hi! First, pardon me if this has been asked before. It's kind of hard to search on this topic. I made a slide using Keynote08 on one mac (MacPro) and copied it to another (Macbook Pro). After opening it on my MBP using exactly the same Keynote08 (ver
-
Testing bluetooth w/out keyboard or mouse?
Hi there.. I just got a (super-quiet) mac Mini after having a noisy G4 tower for years. I continue to see the problems folks are having with bluetooth keyboard and mouse connections. I used wired stuff but want to test out if my unit has this problem