What is SSH forwarding? - ruby

I read a guide. It says that run the following line and forget it.
/usr/bin/ssh-add -K
I am not sure when and where I should use it.
What is SSH forwarding?

Here's an explanation. And another. An "illustrated" one.
Those should give you a general idea of what's going on here.

If you don't know why you need it, you won't need to add it to set up your ruby environment.
Note to others: this is a question relating to setting up his dev environment before people demand it is closed.

That seems to be a Mac OS X specific option to ssh-add. It adds identities to your OS X keychain, so that any later use will already have them handy.
This is different from other kinds of forwarding. My typical use is to do normal ssh-add with no extra options, then ssh -A to forward the agent. Meaning that if I ssh to another host through the first one, my creds are automatically passed on. Very handy.
By far your best bet is to read the manual pages for any options you see used. Ssh comes with great man pages.

Related

How do I log history in a tramp emacs ssh session

I started using tramp with emacs as per the discussion here (Open file via SSH and Sudo with Emacs) in order to use my emacs configs without having to install them on the server/user I was sshing to. Apparently the default setting of this sets HISTFILE=/dev/null, and I got a concerned email from my company's infosec team asking why I was doing this. Is there a way to turn this setting off and log history the normal way? Would like to keep using this tool in compliance with security rules.
Setting HISTFILE=/dev/null is disabled in development version of Tramp, because there is a bug in bash which corrupts /dev/null then. Likely, the security department of your company is concerned about this.
If you have a recent Tramp (say the one bundled with Emacs 24.5), setting HISTFILE=/dev/null is hardwired in tramp-sh.el. You would need to patch it there.
If you install a newer Tramp version like 2.2.12 (see the Tramp manual how to do this), you could use the variable tramp-histfile-override to set your own value. Per default it is set to ".tramp_history", but there are also other possibilities. See the docstring of that variable.

Variables forwarding with SSH on Windows (without PuTTY)

I have a Vagrant/Puppet VM that needs to execute SSH at a certain point and needs to forward the GIT_* variables, so that the server could Authenticate the automatic scripts without failing.
On Linux/Mac that's straightforward. But how to do it on Windows? (I have 8, but I guess is more or less the same for all >XP)
I searched over the net but all the solutions seem to rely on PuTTY, while I don't want to follow that approach (I'm looking for a solution that doesn't rely on PuTTY or Cygwin)
How to forward environment variables through SSH over Windows?
I cannot even find a way to set a custom config file where to put the directives.

How would I create an SFTP connection if my application framework does not contain an API for it?

I am trying to connect to an SFTP server with my AIR application. It doesn't matter that it's an AIR application except that I haven't found any libraries or AIR API methods for it.
My first thought is to find a library in another language and rewrite it in ActionScript. I'd rather not do that and my lack of experience may introduce security issues.
My second thought is to call a native process or command such as sftp or sshpass or curl from my main application and pass the local and remote upload locations to it and let it do the work. The downside to this is if they don't have the command installed they have to install a separate program.
My questions are:
Are these SFTP commands available by default on both Mac and Windows?
Should I store the users login (I do not want to) or prompt them to enter it each time? Does SFTP / public key remove the need for that?
I've found two related questions here and here but some of it is over my head. They also seem to be specific to *nux (which may work for Mac as well but not Windows).
I do not have the experience in this area so I would welcome those with experience to give guidance if this is a good idea or not. Overview type answers are welcome for me as I can attempt to work out the details. If no answer is given, once I've figured it out I'll post an answer. Please do not close this question (rather suggest edits).
FYI I'm using AIR to make a native process call.
An AIR application in the extended desktop profile can execute a file,
as if it were invoked by the command line. It can communicate with the
standard streams of the native process. Standard streams include the
standard input stream (stdin), the output stream (stdout), the
standard error stream (stderr).
I can also create and call a scpt, sh or bat file.
Commands installed on my Mac:
curl_init(), curl_setopt()
ssh
sftp
Commands not installed on my Mac:
sshpass
Are these SFTP commands available by default on both Mac and Windows?
No. There is no sftp nor ssh on windows by default, unless you install it through cygwin or bundle them in your application (also solution).
Should I store the users login (I do not want to) or prompt them to enter it each time?
Prompt is preferred.
Does SFTP / public key remove the need for that?
Yes, but you will have to store private key, which is almost the same like storing password.

MobaXterm drag-and-drop panel missing

I need to run a program from my windows xP machine thats installed on a remote UNIX machine using MobaXterm but I have very little experience with this sort of thing.
I can login into the machine using ssh and start the program without a problem. That program needs files that I have on my windows computer to process though and I want to copy them over to that remote machine. Unfortunately the drag-and-drop file transfer panel that is mentioned regularly on mobaxterm help sites isn't present and I can't figure out how to make it appear.
Could someone suggest how to get that drag-and-drop panel to appear please? I'm using MobaXterm version 3.0.
Alternatively any explanation on how to transfer these files another way would also be very much appreciated.
Thank you very much for any help you can give.
If it still doesn't work when you try all of above methods, try this:
when you creat a Session, change the Advanced SSH setting-->SSH-browser type to SCP, which default is SFTP.
. thanks to willfurnass
Some Linux distributions or some other Unix systems have disabled SSH password authentication by default.
In order for MobaXterm to be able to launch the SFTP browser, you will have to re-enable this feature:
Edit the "/etc/ssh/sshd_config" file on your server, and comment the following line:
PasswordAuthentication no
Restart your SSH server using the following command: /etc/init.d/sshd restart
Connect using MobaXterm SSH client and you will notice that the SFTP tab will be correctly launched.
If you can not modify your remote server configuration, you can also perform your file transfers inside MobaXterm terminal using SCP. A sample SCP command would be:
scp -r /drives/c/Some/Place/On/Your/Local/Windows/Drive/ yourlogin#yourserver:/Some/Place/On/Your/Remote/Unix/Server/
Ensure you have "Display SFTP Browser" enabled in your session settings under "Advanced SSH settings".
Occasionally it doesn't reappear, which is solved by a restart MobaXterm.
Another cause for the lack of sftp panel is if you accidentally enter and store a bad sftp password. MobaXterm then appears to attempt an automatic log in, but silently fails to open the sftp connection.
To fix this, go to Settings>MobaXterm passwords management and delete the offending password. Here's a screenshot of the settings page, showing the password management link.
To be clear, I had already run through the settings mentioned by #Nicolas and #Didier (thanks, guys!). I was able to get the sftp tab when ssh'ing in to other hosts (which didn't have bad passwords stored). And I had in the past seen the sftp pane. This fix solved my problem.
If you've never seen the sftp pane, then try the other suggestions first.
Have you tried:
Turning the program off and on again?
Note: I read this hint in a comment, which saved me from a tidious process of unnecessary fixing mobaXterm, also I am hence not the only one with that behavior. Even though this might be the first thing you already tried, some might not have been trying and haven't been lucky enough to read through the comments - this is for them.
For the most recent versions, ensure you have selected 'SFTP protocol' in the'SSH-browser' selector:

Moving files across a computers connected by LAN

I am needed to move entire directories from one computer in the network to the other (In a platform independent way). Basically I am working on some automation tool to help the developers do Build Verification Tests, for this; I am directed to automate the installation and un-installation of the product on multiple platforms. So, I will need to first copy the files!
And this is where I needed some help in both conceptual and practical knowledge.
Firstly, let me mention that using something like FileZilla or WinSCP is out of the question since I need things to happen automatically and not through button clicks. But please let me know if these tools have any command line utilities!
I tried Perl's NET::FTP, and while it looked promising, I was wondering whether it was the best way to go. Also, I want to know what are the pre-requisites before I can run FTP, I mean would I need perl installed on the other end as well ? I constantly read that the commands from perl's FTP actually try to connect to a FTP host, does this mean its not going to work if I haven't configured the remote host in some way? And if I am right, then what is this extra piece of configuration to be done?
Apart from this, is there any other way I could solve my problem ? I mean I am looking for API's here that would help me do platform independent file transfers. But once again, I cannot use tools that would need button clicks and stuff, because I am doing automation and everything needs be dome programmatic-ally and automatically.
Also, I think this is a very generic problem-statement: "Moving files across a computers connected by LAN"; So, it would be wonderful if we can have a list of (possibly) many options (ways to solve the problem) in the form of answers to this post.
Thanks in advance for any help that you wish to provide.
If nearly all of the files in your directory have changed, creating an archive, sending it over the network, and unarchiving makes sense. Actually, if your LAN is fast enough, though, it may be faster not to compress the archive--just use tar.
If only some of the files have changed, rsync, a command line tool, will only download the changes. It can be used with ssh like this:
rsync -ae ssh username#hostname:/path/to/files /store/here/locally
http://www.thegeekstuff.com/2010/09/rsync-command-examples/
On Linux and OS X, cron and crontab allow you to schedule scripts to run periodically. Windows provides the Windows Task Scheduler.
FTP is fine if you don't care about encryption over your LAN. Otherwise, SSH would be preferable.
rsync is available on OS X and Linux, but I think you can use it on Windows through Cygwin.
I suggest making an archive (e.g. a .tar.gz file) on the source host, transferring it with scp, and unarchive it on the target host.
You could also use unison or rsync
I would suggest you to develop your own FTP client in .NET. This way you will have complete control over the application, and instead of button-clicks you can schedule it using windows-scheduler. Here is an article about how to create your own FTP client in VB.NET:
http://dot-net-talk.blogspot.com/2008/12/how-to-create-ftp-client-in-vbnet.html

Resources